PDA

View Full Version : Link Description Script Not Working - HELP!



gwen32540
09-01-2007, 06:48 PM
1) Script Title: Link Description

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex5/linkdescribe.htm

3) Describe problem: The code below generates an "object expected" error.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<script type="text/javascript" language="JavaScript">
var linktext=new Array();
linktext[0]="Visit Dynamic Drive for some great DHTML scripts!";
linktext[1]="JavaScript Kit, the JavaScript technology center";
linktext[2]="Direct link to hundreds of free java applets online";
var ns6=document.getElementById&&!document.all
var ie=document.all
function show_text(thetext, whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=linktext[thetext]
else if (ns6) document.getElementById(whichdiv).innerHTML=linktext[thetext]
}
function resetit(whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=' '
else if (ns6) document.getElementById(whichdiv).innerHTML=' '
}
</script>

<!-- show_text(index# of linktext[] to show, ID of div to write to) -->

<p>
<a href="http://www.dynamicdrive.com" onMouseover="show_text(0,'div1');" onMouseout="resetit('div1');">Dynamic Drive</a> |
<a href="http://www.javascriptkit.com" onMouseover="show_text(1,'div1');" onMouseout="resetit('div1');">JavaScript Kit</a> |
<a href="http://www.freewarejava.com" onMouseover="show_text(2,'div1');" onMouseout="resetit('div1');">Freewarejava</a>
<br>
<span id="div1"> </span>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I also have the following script at the top of the page. I am only including this here because I want to know whether (a) the Link Description script needs modification, or (b) there is a conflict between the two scripts.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<script language="JavaScript" type="text/JavaScript">
function load_content () {
if (parent.document.getElementById('main_div')) {
parent.document.getElementById('main_div').innerHTML=document.getElementById('inner_frame').innerHTML;
}
if (!parent.document.getElementById('main_div')) {
window.location=('faq.cfm') ;
}
}
</script>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Many, many thanks in advance!

Gwen H

jscheuer1
09-02-2007, 02:15 AM
Describe problem: The code below generates an "object expected" error.

No it doesn't:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
function load_content () {
if (parent.document.getElementById('main_div')) {
parent.document.getElementById('main_div').innerHTML=document.getElementById('inner_frame').innerHTML;
}
if (!parent.document.getElementById('main_div')) {
window.location=('faq.cfm') ;
}
}
</script>
</head>
<body>
<script type="text/javascript" language="JavaScript">
var linktext=new Array();
linktext[0]="Visit Dynamic Drive for some great DHTML scripts!";
linktext[1]="JavaScript Kit, the JavaScript technology center";
linktext[2]="Direct link to hundreds of free java applets online";
var ns6=document.getElementById&&!document.all
var ie=document.all
function show_text(thetext, whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=linktext[thetext]
else if (ns6) document.getElementById(whichdiv).innerHTML=linktext[thetext]
}
function resetit(whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=' '
else if (ns6) document.getElementById(whichdiv).innerHTML=' '
}
</script>

<!-- show_text(index# of linktext[] to show, ID of div to write to) -->

<p>
<a href="http://www.dynamicdrive.com" onMouseover="show_text(0,'div1');" onMouseout="resetit('div1');">Dynamic Drive</a> |
<a href="http://www.javascriptkit.com" onMouseover="show_text(1,'div1');" onMouseout="resetit('div1');">JavaScript Kit</a> |
<a href="http://www.freewarejava.com" onMouseover="show_text(2,'div1');" onMouseout="resetit('div1');">Freewarejava</a>
<br>
<span id="div1"> </span>


</body>
</html>

gwen32540
09-02-2007, 05:51 PM
Actually, I've tested it in the latest versions of Firefox, IE, and Netscape, and yes it does generate an error. Do you perhaps have script debugging turned off in your browser?

I appreciate your effort to help, but I would like to respectfully request that everyone refrain from posting replies to my query unless you have *constructive* information to offer. If you can't see the error message, then you can't help me.

Best regards,
Gwen H

jscheuer1
09-02-2007, 09:10 PM
You must have tested a different page than I did. Try the page in my post. I guarantee, no errors. If there is any error it is with your code:


<script language="JavaScript" type="text/JavaScript">
function load_content () {
if (parent.document.getElementById('main_div')) {
parent.document.getElementById('main_div').innerHTML=document.getElementById('inner_frame').innerHTML;
}
if (!parent.document.getElementById('main_div')) {
window.location=('faq.cfm') ;
}
}
</script>

However, there is nothing in your original post that shows/explains that code getting executed at any time, or for any reason.

Further, if you are still unhappy with my responses and still wish me to stop trying to help, I will be happy to comply.