Hey,
I have started learning Javascript programming, I wrote these two codes and it thy are not working, it shows a blank page when i load those files. Please help.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
function card(name, address, work, homep)
{
this.name=name;
this.address=address;
this.workphone=work;
this.homephone=homep;
this.PrintCard=PrintCard;
}
function PrintCard()
{
line1="Name : "+this.name+"<br />";
line2="Address : "+this.address+"<br />";
line3="Work : "+this.workphone+"<br />";
line4="Home : "+this.homephone+"<br />";
document.write(line1, line2, line3, line4);
}
tom=new Card("Tom Jones","123 Elm Street","9810669558","27355558");
tom.PrintCard();
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
function addHead(level){
html='H'+level;
text=this.toString();
start="<"+html+">";
stop="</"+html+">";
return start+text+stop;
}
String.prototype.heading=addhead;
document.write("This is a headding 1".heading(1));
document.write("This is a heading 2".heading(2));
document.write("This is a heading 3".heading(3));
</script>
</body>
</html>