Slyke Posted December 10, 2008 Report Share Posted December 10, 2008 Why doesCode:theMenuSection.innerHTML='<ul>';alert(theMenuSection.innerHTML);ProduceCode:<ul> </ul>?This is very annoying since the list has a child list inside it and is constructed as the page is loading. Is there any way to prevent JavaScript from closing off the <ul> tag?theMenuSection is a div tag (also tried span).Use this code to reproduce the problem:<span id="testspan"></span><br /><script>var theMenuSectiontheMenuSection=document.getElementById("testspan");theMenuSection.innerHTML='<ul>';alert(theMenuSection.innerHTML);</script>Copy paste it into a text file, and rename to htm, and open it.By the way, I'm using Firefox v3, but I'm sure it does it in IE too. Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted December 11, 2008 Report Share Posted December 11, 2008 I'm not a scripting person, so my suggestion may not be valid at all.What happens if you use '<ul>' instead of '<ul>' ? Quote Link to comment Share on other sites More sharing options...
Slyke Posted December 11, 2008 Author Report Share Posted December 11, 2008 Hey Pat!Yeah I thought about that, but then I remembered that it would display the < and > on the actual webpage, and not create the unordered list. Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted December 11, 2008 Report Share Posted December 11, 2008 As I mentioned earlier, I know not much about JavaScript.What I would do in your situation would be to find the most comprehensive JavaScript reference on the Internet, then see if there is any option like 'noclose' or so. Also look for sample scripts in the many tutorials that are around. Quote Link to comment Share on other sites More sharing options...
Slyke Posted December 11, 2008 Author Report Share Posted December 11, 2008 Some one on the VBForums found the solution. It's quite easy actually, lol.Just don't refer to the innerHTML, refer to theMenuSection directly and place the HTML into there!Thanks for you help :). Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted December 12, 2008 Report Share Posted December 12, 2008 Thanks for the feedback. Quote Link to comment Share on other sites More sharing options...
Slyke Posted December 12, 2008 Author Report Share Posted December 12, 2008 For anyone in the future that maybe interested Here's The Link.It's theMenuSection.html, innerHTML tries to make it XHTML compliant I believe. 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.