I have the following code..for some reason the onClick portion does not work in IE. Any idea how this can be fixed? if ( $.cookie("fb-lk") && $.cookie("fb-sh") ) { $("#multistep-proceed").fadeTo(300, 1).prop("disabled", false).attr("onClick", "loadGTW()"); } } multistep_check(); function loadGTW () { window.open('https://www.mywebsite.com', '_top') } Code (markup):
attr("onClick", "loadGTW()") are you sure the function name should be in quotes? (not a big jq fan, if that is how it should be just another strike against JQ) Also, shouldn't the function be declared BEFORE you try and reference it?
Can't you just redo it to use .on() instead of .attr()? Something like: .on('click', loadGTW()); ? And @deathshadow - as long as he's running it inside the $(document).ready()-container, jQuery waits and reads all before doing anything, hence the function can be declared after the actual $(document).ready() - however, if the function itself is declared within the $(document).ready() container, it should be declared before, indeed.
... and say hello to another reason I'd never use the fat bloated idiotic halfwit BS known as jQuery in the first place... Of course the whole 'ready' nonsense just overcomplicates something simple... like just loading the file right before </body> so the DOM is built and you don't even have to wait for 'ready'?
That is also perfectly possible - it's just that jQuery provides a way to have the js wait for the loading of the page, without having to add the js to the end of the code. Stupid? Perhaps.