IE浏览器button onclick无法跳转JS修改的url

firsthym 2010-02-22 04:26:09
<button onclick="SetUrl()">test</button>
function SetUrl()
{
window.location.href="test.php?q=hello";
}
...全文
360 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
haiyang5210 2011-03-02
  • 打赏
  • 举报
回复
产生这个问题的原因是:
1. <button></button>外面嵌套了<form>标签
2. 没有设button的type

解决方法:<form><button type="button" onclick="javascript:go()" >go</button></form>
firsthym 2010-03-03
  • 打赏
  • 举报
回复
多谢楼上的,我已经修正这个问题了,改用input的button了。
少装点怪 2010-03-01
  • 打赏
  • 举报
回复
你确定路径没错?链接有效?
<button onClick = "location='链接';"></button>
ghostxyz0 2010-03-01
  • 打赏
  • 举报
回复
不造成用这种写法

我记得这种写法在IE6下会有错误
motol 2010-03-01
  • 打赏
  • 举报
回复
首先加下<script type="text/javascript"></script>
IE7下运行正常
不正常的话,你加下onclick="void(SetUrl())"
试试
北京不不 2010-03-01
  • 打赏
  • 举报
回复
<button onclick="SetUrl()">test</button>
function SetUrl()
{
window.location.href="test.php?q=hello";
}

你代码要贴源代码。你看你这小错误这么多。
button控件?

<script>也没有
bliuyanan 2010-03-01
  • 打赏
  • 举报
回复
这个可以再顶.....
zhangleifly 2010-03-01
  • 打赏
  • 举报
回复
function go(url){
setTimeout(function()
{
window.location = url;
}, 0);
}
mykelly6 2010-03-01
  • 打赏
  • 举报
回复
据说window.location.href有时候不识别,最好用window.location,不过我不确定
jusin909 2010-02-28
  • 打赏
  • 举报
回复
定一下,拿点分...
firsthym 2010-02-28
  • 打赏
  • 举报
回复
这是IE7的问题吗?
firsthym 2010-02-23
  • 打赏
  • 举报
回复
我用的是IE7,button那个我误导大家了,那一段只是普通的HTML。

我的问题是,当我点击这个Button时,它会跳转到一个undefine网页上去
phpboy 2010-02-22
  • 打赏
  • 举报
回复
应该是可以的~~~~
hanxianglin 2010-02-22
  • 打赏
  • 举报
回复
<input type="button" onclick="return aaaaa()">

<script>
function aaaaa()
{
window.location.href="www.sina.com";
}
</script>
  • 打赏
  • 举报
回复
我这里可以呀



<button onclick="SetUrl()">test</button>
<script>
function SetUrl()
{
window.location.href="test.php?q=hello";
}
</script>
hanxianglin 2010-02-22
  • 打赏
  • 举报
回复
js当中根本没有button双标记
<!==这是HTML代码==!>
<input type="button" onclick="SetUrl
//下面这是JavaScript代码
[color=#FF0000]<script>
function SetUrl()
{
window.location.href="test.php?q=hello";
}
</script>

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧