1

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");
}
dsgriffin
68.9k17 gold badges141 silver badges139 bronze badges
asked Apr 28, 2013 at 16:56
4
  • 1
    where are you calling this function? Can you show relevant bits from the HTML page? Commented Apr 28, 2013 at 16:59
  • 1
    Do you see any error message in the console? Commented Apr 28, 2013 at 16:59
  • how is this function called? What does your html have? do you see any js errors when the page loads? Commented Apr 28, 2013 at 17:02
  • Please provide a better, expressive title for your question. Commented Apr 28, 2013 at 17:18

2 Answers 2

2
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")?

answered Apr 28, 2013 at 17:00
Sign up to request clarification or add additional context in comments.

1 Comment

@ChristiaanScheermeijer, Average Joe can obviously clear this up, but I doubt it since newel is appended to #list in the previous line.
-1

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.

answered Apr 28, 2013 at 17:03

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.