pnj Posted November 7, 2006 Share Posted November 7, 2006 Is it possible in IE to load an element with an embedded script tag via http get? I can get such a script to run in Firefox, but not in IE.The http get callback function looks like this:function proc_rep () { if (http.readyState != 4) return; // not finished loading p = document.createElement("div"); p.innerHTML = http.responseText; par.appendChild (p);}The file being loaded could be as simple as a script tag with a window.alert() call.In fact the script is more complicated, but even this simple example works in Firefox, but not in IE. Any thoughts?I know that I can load a file in IE if its content is ONLY javascript code, through the .src attribute of a script element created on the fly. But the goal is to load some html markup with embedded script tags.The markup describes an expanding table with the option to delete its own rows via another http get request, hence the need for the script. It sounds convoluted, but works beautifully... in FF. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 7, 2006 Share Posted November 7, 2006 I'm pretty sure I've had to eval() such scripts. Quote Link to comment Share on other sites More sharing options...
pnj Posted November 8, 2006 Author Share Posted November 8, 2006 sorry to be obtuse, but you'll have to spell it out for me. eval() from where since the script tag isn't processed?I could do it as an onload attribute of an img tag... but I'm wondering what specifically you had in mind.The page that is being loaded into a div via http get looks something like this:[code]<sc ript>function row_del() { /* deletes a table row */}</sc ript><table><tr><td>...content...</td><td><a href="javascript:row_del()>delete</a></td></tr></table>[/code]IE doesn't seem to retain anything in the script tag. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 8, 2006 Share Posted November 8, 2006 Yeah, you have to get the script out of the innerHTML. Quote Link to comment Share on other sites More sharing options...
pnj Posted November 9, 2006 Author Share Posted November 9, 2006 So search the response string for an embedded script tag, and eval() the contents, and do this in the process reply function - allowing the script to be retained in the block where it is most logical. But probably I need to use a tag other than the script tag, or in Firefox the script will get evaluated twice. Something like:[code]<!--<evalscript>/* do scripty stuff */</evalscript>-->[/code]Thoughts?-pnj Quote Link to comment Share on other sites More sharing options...
fenway Posted November 10, 2006 Share Posted November 10, 2006 Maybe... I've only ever dealt with this in an IE-only environment. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.