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");
}
-
1where are you calling this function? Can you show relevant bits from the HTML page?Matt Greer– Matt Greer2013年04月28日 16:59:11 +00:00Commented Apr 28, 2013 at 16:59
-
1Do you see any error message in the console?Mike Samuel– Mike Samuel2013年04月28日 16:59:20 +00:00Commented 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?Akshay– Akshay2013年04月28日 17:02:13 +00:00Commented Apr 28, 2013 at 17:02
-
Please provide a better, expressive title for your question.Felix Kling– Felix Kling2013年04月28日 17:18:14 +00:00Commented Apr 28, 2013 at 17:18
2 Answers 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")?
1 Comment
#list in the previous line.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.