window.location的问题 [英] window.location problem

查看:139
本文介绍了window.location的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IE6面临奇怪的问题。

I am facing on strange problem in ie6.

当我使用了window.location通过JavaScript正常工作在所有的浏览器IE6,除了重定向页面。

When i am using window.location to redirect page through javascript it works fine in all browser except ie6.

它工作在IE 6,如果我把就像如下:

It works in ie 6 if i place just like below:

<a href="javascript:void(0);" onclick="javascript:window.location('http://www.demo.com');">demo</a>

但其不工作的低于code。

but its not working for below code.

<a href="javascript:void(0);" onclick="javascript:redirect();>demo</a>
function redirect()
{
  window.location('http://www.demo.com');"
}

您可以请弄清楚,什么这里的问题。

can you please figure out that whats problem here.

感谢。

阿维纳什

推荐答案

的javascript:协议只,如果你有在URL中的Javascript code使用。如果你把它放在一个事件处理程序就成了一个标签来代替。

The javascript: protocol is only used if you have Javascript code in an URL. If you put it in an event handler it becomes a label instead.

位置成员不是一个函数,它是一个对象。将的href 属性来更改位置。

The location member is not a function, it's an object. Set the href property to change the location.

您必须在功能上code线,这可能是导致语法错误后,一个额外的引号。

You have an extra quotation mark after the code line in the function, which is probably causing a syntax error.

<a href="javascript:void(0);" onclick="redirect();>demo</a>

<script type="text/javascript">
function redirect() {
  window.location.href = 'http://www.demo.com';
}
</script>

这篇关于window.location的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆