Results 1 to 4 of 4

Thread: Link Description Script Not Working - HELP!

  1. #1
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Link Description Script Not Working - HELP!

    1) Script Title: Link Description

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...nkdescribe.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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by gwen32540 View Post
    Describe problem: The code below generates an "object expected" error.
    No it doesn't:

    Code:
    <!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>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •