现在的位置: 首页 > 综合 > 正文

location.href语句与火狐不兼容的问题

2012年03月04日 ⁄ 综合 ⁄ 共 376字 ⁄ 字号 评论关闭

使 用了一个点击按钮跳转的js,语句很简单:

<input type="button" value="添加" onclick="location.href('http://www.jb51.net);" />

测试的时候发现其在IE下是可以用的而firefox则不能使用了。于是我在location前面加了一个 window,即改为:

onclick="window.location.href('http://baidu.com');"

发现仍然不行。

于是去baidu之,找到一个答案:

使用window.location="url"; 代替 location.href('url');"

于是将源程序改为如下即可:

<input type="button" value="添加" onclick="window.location='http://www.ddung.org'';" />

抱歉!评论已关闭.