Results 1 to 4 of 4

Thread: javascript "innerHTML" cannot resolve

  1. #1
    Join Date
    Feb 2009
    Posts
    72

    javascript "innerHTML" cannot resolve

    Hi,

    i have taken code from the college friend where i see that on his computer this code was working perfect but for the execution of this code on my computer it gives an error at this point so i just posted only this much error here,please have a look at it and suggest some solution on it.

    Code:
    theMenuSection.innerHTML='<ul>';
    alert(theMenuSection.innerHTML);
    I understand some details about the project and in that project we were creating an list of child 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).

    Thanks in Advance....

  2. #2
    Join Date
    Dec 2008
    Posts
    93

    Re: javascript "innerHTML" cannot resolve

    Using innerHTML method instead of addChild in javascript

    1. In javascript getElementById() method is used to get the HTML form element with the specified Id.
      for example,
      var xxx = document.getElementById("idform");
      will get the HTML form element with the id "idform" and stored in the variable xxx.
    2. Content can be added dynamically to the element using addChild method as,xxx.addChild(someValue);
    3. Instead of using addChild, innerHTML is also used to add value to the element at run time as,
      xxx.innerHTML = 'somevalue';
      or you can use,
      document.getElementById('idForm').innerHTML = 'someValue';
    4. When the innerHTML property is set, the given string completely replaces the existing content of the object.

  3. #3
    Join Date
    Dec 2008
    Posts
    161

    Re: javascript "innerHTML" cannot resolve

    HTML tag can be used to make design and content in web page. If HTML is loaded once, it can not change HTML element�s property. InnerHTML function can modify and replace text content and HTML element of web page.

    innerHTML can embedded with any HTML tags and any text content in HTML page after page is loaded fully on browser.

    By innerHTML, we can change whole HTML tag and define new HTML tags in web page.
    innerHTML function work as normal html embedding in current page. HTML tag we used should nest properly. Otherwise structure of previous HTML can damage. If we use tags through innerHTML, tag should be closed.

    The example of innerHTML can work with getElementById. We are using to add HTML table element in web page which is completed loaded on browser. Another example is simple of innerHTML to add text context in web page. Third example of innerHTML is to take input from user and make innerHTML on run time.

  4. #4
    Join Date
    Jan 2009
    Posts
    92

    Re: javascript "innerHTML" cannot resolve

    If you do an alert( div.innerhtml ) all script tags and internals are missing whereas <a onclick="javascript: hello(); return false"> survives untouched.

    I don't understand the rules, you can access the javascript within the head section via dom functions, I don't think you can for script within the body (within script tags) as for the anon functions such as the onclick= stuff you can get to it via element.onclick.

    If you have control of all the source, then more all the javascript into the head section, if you are dealing with random html from some other source life is more interesting.

Similar Threads

  1. Replies: 4
    Last Post: 25-11-2010, 03:03 AM
  2. Replies: 6
    Last Post: 18-05-2010, 12:27 AM
  3. href="javascript:func()" vs href="#" onclick="javascript:func()"
    By BansiJI in forum Software Development
    Replies: 6
    Last Post: 12-05-2010, 10:02 AM
  4. How to resolve the error "Disk boot failure"
    By James Afflek in forum Guides & Tutorials
    Replies: 4
    Last Post: 21-04-2009, 10:24 AM
  5. Can't open Hotmail msgs, "javascript;" @ lower left
    By Klangpup in forum Vista Help
    Replies: 3
    Last Post: 06-07-2008, 07:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,726,700.54967 seconds with 16 queries