![]() |
Javascript .play() and .pause() HTML5 methods - IE8
Hi there.
Well aware IE8 won't support my html5 audio or video, thats no problem what so ever. However I have some javascript that plays these at certain points, some on hover, some on click, doc load etc etc. The problem is IE8 doesn't recognise it, and therefore doesn't execute anymore of my javascript, even other functions. e.g. $(document).ready(function() { $('#music').pause(); // Not supported in IE8 function() { // Supported in IE8 yet not running. due to the above. Whatever code } } How can I make IE8 ignore these methods? Thanks lifesavers! |
I'm not sure about the specifics of the audio player, but generally you can test for the existence of a function before calling it, and wrap the necessary code in that code block
Code:
if($('#music').pause()){ |
Hey thanks for your quick reply. There is no player as such, it's in the background (invisible if you will.)
I've stripped out the jQuery back to Vanilla and got this but it's still not liking it, any suggestions? if (document.getElementById('js-video').pause()) { document.getElementById('js-video').pause(); alert('1'); } // Check if support if (document.getElementById('js-audio').pause()) { document.getElementById('js-audio').pause(); alert('2'); } Chrome pauses fine, except alerts don't appear. IE8 still won't load rest of JS. Thanks. :) |
just guessing really, but you might need to go one step further:
Code:
if (typeof(document.getElementById('js-video').pause())!="function") { |
One important mistake: You should check the method and not the result of the method execution. Bottom line: You have to omit the parentheses.
Code:
if (typeof document.getElementById('js-video').pause !== "function") { |
:thumbsup:
|
Sorry late reply. Thanks for this guys, much appreciated and should have known!
|
| All times are GMT +1. The time now is 09:57 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.