简体   繁体   English

javascript String.split在Chrome中不起作用

[英]javascript String.split not working in chrome

i am trying to split a string in javascript . 我试图在javascript中拆分字符串。 it works fine in firefox but, it fails in chrome. 它在Firefox中工作正常,但在chrome中失败。 could anyone please share the ideas in this. 任何人都可以在此分享想法。

i used the following code: 我用下面的代码:

var v="asd.sdf";
var arr=v.split('.');

I just faced this problem on chrome. 我只是在Chrome上遇到了这个问题。 After some couple of page refreshing the problem disappeared. 经过几页刷新后,问题消失了。

I just tried it in Chrome 17.0.963.78 and it works fine: 我只是在Chrome 17.0.963.78中尝试过,但效果很好:

<script type="text/javascript">

var str="asd.sdf";
var arr = str.split(".");
document.write(arr);
document.write("<br />DONE<br />");
document.write(str.split(".") + "<br />");


</script>

Gave: 给予:

asd,sdf
DONE
asd,sdf

What am I doing that is different to you? 我在做什么与您不同?

This kind of bug is most often some other code in that session corrupting the global String objects split function. 这种错误通常是该会话中的某些其他代码破坏了全局String对象拆分功能。

Try the same code in a very basic web page with no other javascript. 在没有其他JavaScript的非常基本的网页中尝试相同的代码。

If it still doesn't work It is possible that this can be caused by dodgy plugins, so try disabling any plugins. 如果仍然不起作用,则可能是由于躲闪的插件引起的,因此请尝试禁用所有插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM