Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > This code do not work in IE?

Reply
Thread Tools

This code do not work in IE?

 
 
Thomas Jansen
Guest
Posts: n/a
 
      08-03-2007
Hi,

IE reports an unknown error with this code.
But with Firfox and Opera there is no problem running the code.
Any hint why?

// response = var sMessage = "Hello, ";| var sName = "Your Name";|
callback(sMessage + sName);
var response = decodeURIComponent(http.responseText);
alert(response);
var olist = response.split('|');

var s = document.createElement("script");
s.type = "text/javascript";
s.innerHTML = (olist[0]);
s.innerHTML += (olist[1]);
s.innerHTML += (olist[2]);
document.body.appendChild(s);

~TJ
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      08-03-2007
Thomas Jansen wrote:

> IE reports an unknown error with this code.
> But with Firfox and Opera there is no problem running the code.
> Any hint why?



> var s = document.createElement("script");
> s.type = "text/javascript";
> s.innerHTML = (olist[0]);
> s.innerHTML += (olist[1]);
> s.innerHTML += (olist[2]);
> document.body.appendChild(s);


IE allows you to create most elements with createElement but is a bit
picky about other actions like appendChild or setting innerHTML when it
comes to script or style elements. You should be able to set the text
property of script elements in IE, Opera, Mozilla e.g.

var script = document.createElement('script');
script.type = 'text/javascript';
script.text = 'alert("foo");';
document.body.appendChild(script);

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Thomas Jansen
Guest
Posts: n/a
 
      08-03-2007
Martin Honnen skrev:
> Thomas Jansen wrote:
>


> var script = document.createElement('script');
> script.type = 'text/javascript';
> script.text = 'alert("foo");';
> document.body.appendChild(script);
>


Thank you scripts.text was the solution.

~TJ
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE;Kontki if you delete kontiki any program you loaded with it in it 'will not work I have tried it with three programs and none work anymore (if you se it just stop download) 1-Twitch Computer Support 5 04-23-2009 02:45 PM
How can I work on VIM for python code such as cscope for C code? Evan Python 1 09-12-2007 11:55 AM
MS work around on text wrapping in a datagrid does not work TB ASP .Net 2 02-22-2006 10:34 PM
Hi I am new to asp i can not get it to work on xp pro sp2 even though the localhost work but asp pages dont so can some one help craig dicker ASP .Net 9 07-07-2005 11:52 AM
Re: Those cute little "WORK-SAFE" / "NOT WORK-SAFE" tags that people put in the Subject headers of their posts... Soapy Digital Photography 1 08-16-2004 12:07 PM



Advertisments