Always check to be sure the properties and methods you are using are available in the browsers you want the script to run on.
For instance with:
Code:
addPageStateHandler
I've never heard of that one before. Unless it is defined elsewhere in code you haven't shown, it may be an IE proprietary function.
By the same token:
is (I believe) an IE only property. The closest cross browser equivalent would be:
which will work in IE as well, and should do the job at least as far as that part goes.
To check if a particular command is available in a particular browser, Google may often be used to research that.
Also one can do something like:
Code:
alert(typeof object.property_or_method);
Like with innerText, one may see it is not supported in Firefox with this test:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
onload = function(){alert(typeof document.getElementsByTagName('span')[0].innerText);};
</script>
</head>
<body>
<span>Hi</span>
</body>
</html>
In IE it will give you:
string
In Firefox:
undefined
Bookmarks