Average_Joe
Average_Joe

Reputation: 27

Function! Need Assistance

I'm having confusion with the function im using. I'm trying to show an alert message that pops up when the page first loads and also trying to show the user which browser they are currently using, using the Window.navigator Object, theres a few things i still need but nothing is coming up from the code i inputed. Some pointers? or maybe a solution to what i should do?

Heres the js:

function myFunction_3() {    
    var newel = document.createElement("Skills");    
    var text = document.createTextNode("Proficient with");      
    txt = "<p>Browser CodeName: " + navigator.appCodeName + "</p>";   
    document.getElementById("flow").innerHTML=txt;    
    newel.appendChild(text);        
    document.getElementById("list").appendChild(newel);    
    newel.appendChild("rightcol")       
    alert("Page is loaded");
}

Upvotes: 1

Views: 88

Answers (2)

JBrooks
JBrooks

Reputation: 10013

At the bottom of your page call the function:

  <script type="text/javascript">
       myFunction_3();
    </script>     

I say at the bottom because it needs to run after all the controls on the page are created.

Upvotes: -1

Mike Samuel
Mike Samuel

Reputation: 120516

newel.appendChild("rightcol")

is going to fail with an exception because "rightcol" is a string, not a DOM node.

Did you meant to create an element with id "rightcol" but forgot to code that, or pull out part of the existing DOM using document.getElementById("rightcol")?

Upvotes: 2

Related Questions