Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

IE unknown runtime error document.getElementById and innerHTML

Similar to a previous problem reported



8:05 pm on Jul 15, 2008 (gmt 0)

5+ Year Member

Getting the dreaded unknown runtime error in IE (works fine lasts along time in FF). Pulling my hair out (and there is very little of that left to start with).

To see in action: [http://www.fengshuinetwork.net/testindexfsnnew3.php]
Note: this is a test page where all the links should be working and pointing where they are to eventually go BUT none of them come back so browser back button will have to be used if click one; exception is the anchor links on left navbar under heading of Accredited/CPD etc. Rest of scripting for that is unfinished at this point.

Very simple javascript routine in a js file:
function swapLink(n)
{ elem = document.getElementById("leftmenu");
elem.innerHTML = eval("leftmenu" + n);

var leftmenu0 = ('<b><u>Header for Section of Links</u></b>'
+'<li><a href="link1" class="navlinklt">Link1</a></li>'
+'<li><a href="link2" class="navlinklt">Link2</a></li>'

var leftmenu1 = ('<b><u>Header 2 for Section of Links</u></b>'
+'<li><a href="link3" class="navlinklt">Link3</a></li>'
+'<li><a href="link4" class="navlinklt">Link4</a></li>'


Source code for the offending area is as follows (can view all of it from browser(s))...Firefox works fine, IE giving me the error:

<!--------------BEGIN LEFT NAVBAR--------------->
<div class="navbarleft">

<div id="leftmenu">
<b><u>FENG SHUI Network</u></b>
<li><a href="test_about.htm" class="navlinklt">About the FSN</a></li>
<li><a href="contact_fsn.htm" class="navlinklt">Contact the FSN</a></li>
<li><a href="latest_news.htm" class="navlinklt">Latest News</a></li>
<li><a href="visitor_comments_page.htm" class="navlinklt">Visitor's Comments</a></li>
<li><a href="fsn_logo.htm" class="navlinklt">About the FSN Logo</a></li>
<li><a href="submit_events.htm" class="navlinklt">Submit Events</a></li>
<li><a href="site_index.htm" class="navlinklt">FSN Site Index</a></li>
<li><a href="site_search.htm" class="navlinklt">FSN Site Search</a></li>
<li><a href="spam_policy.htm" class="navlinklt">Spam Policy</a></li>
<li><a href="links.htm" class="navlinklt">Links</a></li>
<li><a href="copyright.htm" class="navlinklt">Copyright</a></li>
</div><!--end leftmenu-->

<p><b><u>Accredited / CPD Program Members</u></b>

**********This code works fine***************


</div><!--------------END LEFT NAVBAR----------------->

<!-------------BEGIN UPPER NAVBAR------------------->
<div class="navbarupper">
<table width="1005" border="0" style="font-size: 10pt">
<td align="center"><a href="testindexfsnnew.html" class="navlinkup" onMouseover="swapLink(0)"><img border="0" src="images/fsnlogo.gif" alt="To return to intro click here..." width="201" height="161"><br>FENG SHUI Network</a></td>
<td align="center"><a href="members/index.htm" class="navlinkup" onMouseover="swapLink(1)"><img border="0" src="images/globe.jpg" alt="Members Area" width="160" height="161"><br>Members</a></td>
<td align="center"><a href="mailinglist/subscribe.php" class="navlinkup" onMouseover="swapLink(2)"><img border="0" src="images/mail.gif" alt="Mailing List" width="160" height="161"><br>Mailing List</a></td>
<td align="center"><a href="newsletters/index.htm" target="_blank" class="navlinkup" onMouseover="swapLink(3)"><img border="0" src="images/sspace.jpg" alt="Newsletters" width="160" height="161"><br>Sacred Space</a></td>
<td align="center"><a href="topics/index.htm" target="_blank" class="navlinkup" onMouseover="swapLink(4)"><img border="0" src="images/topics.gif" alt="Topics and Articles" width="160" height="161"><br>Topics & Articles</a></td>
<td align="center"><a href="products/index.htm" class="navlinkup" onMouseover="swapLink(5)"><img border="0" src="images/products.jpg" alt="Products" width="160" height="161"><br>Products</a></td>

</div><!-----------------END UPPERNAVBAR-------------------->

I've made sure closed and covered all the UL and LI tags both in source html and scripting (php coding is working fine and doing what it is supposed to) which appeared to be the problem in the previous thread I looked at about this error.

The way the page works is when "wave" (onmouseover) the mouse pointer over upper links (<div absolutely positioned section with a table>), left navbar displayed links will change (leftnavbar is also in an absolutely positioned <div> area with another "identified" (for the javascript routine i.e. "leftmenu") <div> nested inside that division)

Any help or ideas on this would be greatly appreciated. I'm going to have to hold myself back now and stop tinkering with it until I get some responses so I hope this forum is active and quick LOL.

- Dan


8:46 pm on Jul 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

function swapLink(n)
var elem = document.getElementById("leftmenu");
var res_eval = eval("leftmenu" + n);
var newdiv = document.createElement("div");
newdiv.innerHTML = res_eval;
elem.innerHTML = '';



8:59 pm on Jul 15, 2008 (gmt 0)

5+ Year Member

Thanks, I tried that and same thing happening. Not sure exactly what IE was doing that your solution would of or should have worked but right now that didn't do it. Again I appreciate the feedback. (Fire Fox still works with that new code)...
- Dan


9:01 pm on Jul 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

It works perfectly - I used your source and your js file.


9:18 pm on Jul 15, 2008 (gmt 0)

5+ Year Member

Thats weird because its not working on my computer (in IE). Is there something going into the cache i.e. where need to disable caching the thing that could be affecting how a subsequent (even though I'm set to check for new) load? Maybe using external js and css files are affecting subsequent loads of the page though when this started I hadn't messed with the js or css files at all so "cached" versions of them shouldn't have affected anything. Again, Mozilla is working still.


9:22 pm on Jul 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Check your StickyMail - I sent you the altered source (with the js inline for ease) - works in IE 7, FF3, and the latest Opera on Windows - try clearing your cache.


9:35 pm on Jul 15, 2008 (gmt 0)

5+ Year Member

Thanks again...looks like the fix is actually not using an external js file and putting it all in the header instead because that is the only thing different now from how I have it in the online version.

I'll try it.


9:50 pm on Jul 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I just tested with the js in an external file - works fine. Your have a problem with your testing environment.


9:57 pm on Jul 15, 2008 (gmt 0)

5+ Year Member

I guess so...it works fine now with the js in the header (with your corrections to the function...doesn't work in header with original function). Curious what the difference is or why IE wouldn't work with original. Funny thing...original script has worked some times and not others (after I add or change something that shouldn't affect anything with the javascript routine...i.e. move order of some of the absolutely positioned divs in the source code which shouldnt affect anything else OR add additional code to another division). I thank you again and not sure what is wrong on my desktop computer here but must have some setting that has gotten out of whack which affects this and (apparently) nothing else.

Featured Threads

Hot Threads This Week

Hot Threads This Month