SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Sep 17, 2004, 00:32 #1
- Join Date
- Sep 2004
- Location
- Vancouver,BC
- Posts
- 32
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
js file link doesn't work in innerHTML?
I dynamically change a div's content by its innerHTML, but it seems the js link doesn't work, does it suppose to be like that? how to add js file link in innerHTML?
thanks!
-
Sep 19, 2004, 10:30 #2
Show us the code you're using.
• It may be that you aren't properly nesting the various values.
• It could be that you're not escaping the internal quotes.
• It could be that you're trying to use innerHTML to directly address and alter the javascript link when you need to use it to refer to the markup that contains the javascript link.
Fwiw, take a look at this…
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Untitled</title> <script type="text/javascript"> function linkSwap() { var thisId = document.getElementById('thisThing'); thisId.innerHTML = "<a href=\"#\" onclick=\"window.location='two.html';return false;\">Link 2</a>"; } </script> </head> <body> <p> <a href="#" onclick="linkSwap();">linkSwap</a> </p> <p id="thisThing"> <a href="#" onclick="window.location='one.html';return false;">Link 1</a> </p> </body> </html>
New Plastic Arts: Visual Communication | DesignateOnline
Mate went to NY and all he got me was this lousy signature
-
Sep 19, 2004, 20:30 #3
- Join Date
- Sep 2004
- Location
- Vancouver,BC
- Posts
- 32
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
js code in event works fine, I am talking about js code like this
test.innerHTML="<div id=\"testnode\"><script language=\"JavaScript\" type=\"text/javascript\">alert(\"test\");</script></div>";
in my another thread, I described what I encountered, when I assign those code to a div tag by createdelement by looping through the source div, the alert works fine, but not work when I use innerHTML.
Bookmarks