I am trying to get the code to write the users name onto the site.
I think i need to call the functon before the page fully loads can someone tell me how to do this or how to fix my problem thanks..
I think i need to call the functon before the page fully loads can someone tell me how to do this or how to fix my problem thanks..
Code:
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function getName() {
var name = prompt("What is your name?", "")
}
document.write("Hello " + name + " welcome to my site");
</SCRIPT>
</head>
<body>
<BODY onLoad="getName()">
<SCRIPT LANGUAGE="JavaScript">
document.write("Hello " + name + " welcome to my site");
</SCRIPT>
</body>
</html>
Comment