Let'u start with following example:
Create three pages in same directory: test.html index.html
Your test.html:
<html>
<head>
<script>
function test()
{
alert('Going to google.com?');
window.location="http://google.com";
}
</script>
</head>
<body>
<a href='' onclick="test();">google.com</a><br/>
<input type="button" value="google" onclick="test();" />
<a href='' onmouseover="test();">google.com</a><br/>
</body>
</html>
Now check test.html page on IE as well as firefox or crome.
You will notice following points:
- Button works perfectly.
- First hyperlink works differently in IE and other browser. In IE, it brings us back to index.html page, while in firefox, it stays on same page.
- For first hyperlink, window.location fails.
- Second hyperlink you cannot click on that, as mouse over event will fire first, and it works perfectly!
Why?
My major interest is on 3rd point, as it even gives us alert, window.location fails.