I am facing on strange problem in ie6.
When i am using window.location to redirect page through javascript it works fine in all browser except ie6.
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>
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.
Thanks.
Avinash
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.
The location
member is not a function, it's an object. Set the href
property to change the location.
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>
How about doing this:
<a href="#" onclick="redirect(); return false;">
demo
</a>
如果要在用户单击链接时将页面重定向到demo.html
,我敢建议您使用通用的跨浏览器<a href="demo.html">demo</a>
吗?
Try:
window.event.returnValue = false; document.location.href='http://www.demo.com';
Try:
window.location.href = 'http://www.demo.com';
in the function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.