-
1. Re: javascript problem with internet explorer
David_Powers Aug 28, 2012 11:07 AM (in response to NessaFrankling)NessaFrankling wrote:
Unfortunately this works perfectly on every browser except from blody internet explorer. I can for the life of me work out why this is any pointers would be much appreciated.
IE 9 has a very useful set of Developer Tools, which you access by pressing F12. If you open the Console, it tells you that the problem is on line 30 of testimonails.js. The history object in IE doesn't support the pushState() method.
-
2. Re: javascript problem with internet explorer
NessaFrankling Aug 29, 2012 1:20 AM (in response to David_Powers)Hi David
Thanks for this. Can you suggest another way of doing this so that it works accross all browsers?
-
3. Re: javascript problem with internet explorer
David_Powers Aug 29, 2012 2:58 AM (in response to NessaFrankling)No, sorry. That JavaScript file is more than 2000 lines long. I suggest that you contact the author of the file, and report the fact that it doesn't work in IE 9. The script is doing a lot of browser sniffing to find out which make and version of browser is being used. The error lies in that part of the code rather than just in line 30.
-
4. Re: javascript problem with internet explorer
NessaFrankling Aug 29, 2012 3:04 AM (in response to David_Powers)Hi David
Which file do you mean is 2000 lines long as the file i was talking about is only 60 lines long?
-
5. Re: javascript problem with internet explorer
David_Powers Aug 29, 2012 3:10 AM (in response to NessaFrankling)I've just checked testimonials.js at the URL you originally gave. It's 2007 lines long. I also ran it through the Developer Tools in IE 9, and it confirms that the error is on line 30 of that 2007-line script.
-
6. Re: javascript problem with internet explorer
NessaFrankling Aug 29, 2012 10:20 AM (in response to David_Powers)Hi David
My apologies for this I had been testing something to fix the problem and I had left the code on there. If you look again theis code is 60 lines long. Any help would be much appreciated.
-
7. Re: javascript problem with internet explorer
David_Powers Aug 29, 2012 10:43 AM (in response to NessaFrankling)The history.pushState() method is a new HTML5 feature, which IE apparently doesn't support until IE 10.
You can either use history.js to provide a cross-browser solution, or you can try using a nonstandard IE feature. According to an article in the Mozilla Developer Network, IE supports a string URL as a parameter for history.go().
I haven't tried it out, but you might be able to adapt line 25 like this:
if (window.history.pushState) {
window.history.pushState('data', "Title", "/client-testimonials.html");
} else {
window.history.go("/client-testimonials.html");
}
Also change line 30 like this:
if (window.history.pushState) {
window.history.pushState('data', "Title", "/client-testimonials.html#" + scope);
} else {
window.history.go("/client-testimonials.html#" + scope);
}
-
8. Re: javascript problem with internet explorer
NessaFrankling Aug 30, 2012 4:48 AM (in response to David_Powers)Hi David
PERFECT this works a treat many thanks for this you are a star. I was looking at the history.js but I couldn't really get my head around it.but the second bit of code you supplied works great.
-
9. Re: javascript problem with internet explorer
David_Powers Aug 30, 2012 9:15 AM (in response to NessaFrankling)I'm glad that worked. I wasn't aware that IE supported that nonstandard use of history.go() until I stumbled across it on the Mozilla site.
In one sense, life will be a lot simpler when all browsers support the new JavaScript APIs because the same script should work anywhere. But it will become a lot more complicated because there will be so many features we'll have to remember how to use.