1) language has been depreciated use
Code:
<script type="text/javascript">
</script>
2) and you should also use the doctype 4.01 so the browser can correctly identify and render your code properly
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>PAGE TITLE</title>
</head>
now as for your functions put this inside your <head></head> tag.
Code:
<script type="text/javascript">
function getFavorites() {
var name = prompt("What is your name?", "");
var site = prompt("What is your favorite website?", "");
document.write("<h1>Welcome" +name+ "</h1>");
document.write('<p>Your favorite website is <a href="' +site+ '">' +site+ '</a></p>');
}
</script>
and your body would look something like
Code:
<body>
<form action="void(0)" method="get">
<input type="button" onclick="getFavorites()" value="My Name">
<input type="button" onclick="getFavorites()" value="My Favorite Site">
</form>
</body>
</html>
Bookmarks