Click to See Complete Forum and Search --> : JavaScript errors
Susan
02-24-2003, 08:01 AM
I purchased book but examples of JavaScript give me errors. I wonder if it is because of differences between Netscape and IE. Is there any good references one look at to get hints as to the differences?
I have Microsoft IE6. Does the MSE recognize JavaScript or is it looking for JScript? And could this be my problem?
Thanks for any information!
Susan
khalidali63
02-24-2003, 08:40 AM
Uless you post the specific code fragment and the error that is being caused it really not easy to guess.
Cheers
Khalid
Susan
02-24-2003, 11:59 AM
Okay here is the code. I am having problems with the functions. I get an "object expected" error. I copied this from a book and I haven't been able to figure out what is wrong!
I have Windows ME, IE6. Thanks for any help!
Susan
<html>
<head>
<title>Using Hierarchical Object Identifiers</title>
<script Language="JavaScript">
<!-- Hide from Old Browsers
outputWindow = open("","output")
function setupWindow() {
outputWindow.document.write("<html><head><title>Output Window</title></head></body>")
}
function describeBrowser() {
outputWindow.document.write("<h2>Browser Properties</h2>")
outputWindow.document.write(navigator.appCodeName+" ")
outputWindow.document.write(navigator.appName+" ")
outputWindow.document.write(navigator.appVersion+"<BR>")
outputWindow.document.write(navigator.mimTypes.length+ " MIME types are defined." )
outputWindow.document.write(navigator.plugins.length+" plug-ins are installed.")
}
function describeWindow() {
outputWindow.document.write("<H2>Window Properties</h2>")
outputWindow.document.write("Frames: "+frames.length+"<br>")
outputWindow.document.write("URL: "+LOCATION.HREF+<br>")
}
function describeDocument() {
outputWindow.document.write("<h2>Document Properties</h2>")
describeLinks()
describeForms()
}
function describeLinks() {
outputWindow.document.write("<h3>Links</h3>")
outputWindow.document.write("This document contains "+document.links.lengh+" links:<br>")
for(i=0;i,document.links.length;++i)
outputWindow.document.write(document.links[i].href+"<br>")
}
function describeForms() {
outputWindow.document.write("<H3>Forms</h3>")
for(i=0;i,document.forms.length;i++i) describeForm(i)
}
function describeForm(n) {
outputWindow.document.write("Form "+n+" has " +document.forms[n].elements.length+" elements:")
for(j=0;j<document.forms[n].elements[j].name)
outputWindow.documetn.write("<br>")
}
Function finsihWindow() {
outputWindow.document.write("<FORM><INPUT Type='button'
Value='Close Window' onClick='window.close()'></FORM>")
outputWindow.document.write("</BODY></HTML>")
}
// -></script>
</head>
<body>
<h1>Using Hierarchiacal Object Identifiers</h1>
<p><a href="http://jaworski.com/javascript">Link to Mastering JavaScript and
JScript home page.</a></p>
<p><a href http://home.netscape.com/">Link to Netscape's homepage.</a></p>
<form>
<p><input TYPE="TEXT" NAME="textfield1" VALUE="Enter text here!"
size="20"></p>
<p><input TYPE="CHECKBOX" NAME="checkbox2" value="ON"> I'm checkbox2.</p>
<p><input TYPE="SUBMIT" NAME="submitButton" Value="Click here!"> </p>
</form>
<script language="JavaScript">
setupWindow()
describeBrowser()
describeWindow()
describeDocument()
finishWindow()
// -></script>
</body>
</html>
Dan Drillich
02-24-2003, 07:12 PM
Try this - ;)
<html>
<head>
<title>Using Hierarchical Object Identifiers</title>
<script Language="JavaScript">
<!-- Hide from Old Browsers
outputWindow = open("","output")
function setupWindow() {
outputWindow.document.write("<html><head><title>Output Window</title></head></body>")
}
function describeBrowser() {
outputWindow.document.write("<h2>Browser Properties</h2>")
outputWindow.document.write(navigator.appCodeName+" ")
outputWindow.document.write(navigator.appName+" ")
outputWindow.document.write(navigator.appVersion+"<BR>")
outputWindow.document.write(navigator.mimeTypes.length+ " MIME types are defined." )
// mimTypes -> mimeTypes
outputWindow.document.write(navigator.plugins.length+" plug-ins are installed.")
}
function describeWindow() {
outputWindow.document.write("<H2>Window Properties</h2>")
outputWindow.document.write("Frames: "+frames.length+"<br>")
outputWindow.document.write("URL: "+location.href+"<br>")
// LOCATION.HREF -> location.href
// adding " before <br>"
}
function describeDocument() {
outputWindow.document.write("<h2>Document Properties</h2>")
describeLinks()
describeForms()
}
function describeLinks() {
outputWindow.document.write("<h3>Links</h3>")
outputWindow.document.write("This document contains "+document.links.length+" links:<br>")
// -> length
for(i=0;i<document.links.length;i++) {
// , -> < and ++i -> i++
outputWindow.document.write(document.links[i].href+"<br>")
}
}
function describeForms() {
outputWindow.document.write("<H3>Forms</h3>")
for(i=0;i<document.forms.length;i++){ describeForm(i) }
// same
}
function describeForm(n) {
outputWindow.document.write("Form "+n+" has " +document.forms[n].elements.length+" elements:")
for(j=0;j<document.forms[n].elements[j].name;j++)
// adding ;j++
outputWindow.document.write("<br>")
// documetn -> document
}
function finishWindow() {
// Function -> function
// finsihWindow -> finishWindow
outputWindow.document.write("<FORM><INPUT Type='button' Value='Close Window' onClick='window.close()'></FORM>")
outputWindow.document.write("</BODY></HTML>")
}
// -></script>
</head>
<body>
<h1>Using Hierarchiacal Object Identifiers</h1>
<p><a href="http://jaworski.com/javascript">Link to Mastering JavaScript and
JScript home page.</a></p>
<p><a href http://home.netscape.com/">Link to Netscape's homepage.</a></p>
<form>
<p><input TYPE="TEXT" NAME="textfield1" VALUE="Enter text here!"
size="20"></p>
<p><input TYPE="CHECKBOX" NAME="checkbox2" value="ON"> I'm checkbox2.</p>
<p><input TYPE="SUBMIT" NAME="submitButton" Value="Click here!"> </p>
</form>
<script language="JavaScript">
setupWindow()
describeBrowser()
describeWindow()
describeDocument()
finishWindow()
// -></script>
</body>
</html>
Susan
02-24-2003, 10:08 PM
Thank you very much. I was trying to figure out my mistakes and I made plenty but I was looking in the wrong places. I am new at this and was surprised to find out that mistakes on down in the code can cause things that are correct in the beginning to show as errors. I thank you for your time.
Susan