Discussion:
How 2 insert Javascript through innerhtml?
(too old to reply)
tochiro
2007-12-02 13:28:39 UTC
Permalink
Hello,

I insert a block of html in a web page through the innerhtml method.
This block of html contains a javascript function that lies in an
external javascript file referenced in the head tag of the web page.

The problem is that this function does not work. I cannot find why.

Can you help me? Thank you.
m00n
2007-12-09 17:45:40 UTC
Permalink
Post by tochiro
Hello,
I insert a block of html in a web page through the innerhtml method.
This block of html contains a javascript function that lies in an
external javascript file referenced in the head tag of the web page.
The problem is that this function does not work. I cannot find why.
Can you help me? Thank you.
innerHTML is supported by both FireFox and Internet Explorer, but I only get
it to work after changing the default DreamWeaver page validation:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
wilson
2007-12-20 20:19:02 UTC
Permalink
Post by tochiro
Hello,
I insert a block of html in a web page through the innerhtml method.
This block of html contains a javascript function that lies in an
external javascript file referenced in the head tag of the web page.
The problem is that this function does not work. I cannot find why.
Can you help me? Thank you.
I'm struggling with this is well. Did you come up with a solution
yet? Thanks! Wilson
My Pet Programmer
2007-12-22 12:48:56 UTC
Permalink
Post by wilson
Post by tochiro
Hello,
I insert a block of html in a web page through the innerhtml method.
This block of html contains a javascript function that lies in an
external javascript file referenced in the head tag of the web page.
The problem is that this function does not work. I cannot find why.
Can you help me? Thank you.
I'm struggling with this is well. Did you come up with a solution
yet? Thanks! Wilson
If you have this:

document.getElementById('divID').innerHTML = "<script type = .......";

Then you're not going to get it to work in most browsers. Usually I end
up inserting it into an element via document.write, and you have to
split the strings up so the browsers will even let you do it. But that's
hacky and kinda silly anyway, with the way the dom works.

Maybe you could post a code snippet, so I can give you a little bit more
help than just guessing?

All the best,
~A!

Loading...