Author Topic: Problem with calling javascript in IE  (Read 442 times)

Offline Aliss

  • Level 9
  • *
  • Posts: 54
  • Reputation: +1/-1
    • View Profile
Problem with calling javascript in IE
« on: March 22, 2010, 08:09:58 AM »
I have this code what handles calling javascript in div where is loaded my games content like character menu or battle. And firefox, google chrome and opera all works perfectly. But recently i encountered that in IE it for some strange reasons don't wanna work.

Her is javascript code.

Code: [Select]
// TO CONTAIN JAVASCRIPT
// Loop through the script tags contained within object and execute them
function execute_js(object) {
// As we have loaded the page we will want to execute any javascript we
// can find on the page
var scripts = object.getElementsByTagName("script");
for(var i=0; scripts.length; ++i)
{
if(scripts[i].innerHTML)
eval(scripts[i].innerHTML);
}
}

I hope someone could help me fix this function to work in damn IE.

Offline neuronix

  • Level 3
  • *
  • Posts: 6
  • Reputation: +0/-0
    • View Profile
Re: Problem with calling javascript in IE
« Reply #1 on: March 24, 2010, 03:53:13 AM »
The innerHTML attribute does not exist for script tags in IE and that's what is causing your problem.

I do not exactly understand why you are trying this ...

Easier way is to add script tags with the right src attribute, the browser will execute the script all by itself.

Otherwise look at jquery's getScript : loads remote code and executes it.




 


SimplePortal 2.3.3 © 2008-2010, SimplePortal