Results 1 to 2 of 2

Thread: Live date script

  1. #1
    Join Date
    Jun 2007
    Location
    North Lake Tahoe
    Posts
    62
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Live date script

    http://www.dynamicdrive.com/dynamicindex6/clock3.htm

    Does this script conflict with other java scripts? I've cou and pasted the above script to notepad then to my webpage and nothing happens. I created a new page and it works on it, but that's not what I want.
    Here's a test page on my site: www.noahsvideo.com/time1.html
    Any help would be gratefully appreciated

  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

    Yes. Many older scripts (and this one qualifies for that) as well as some more recent ones use the onload function of the window or the body. Unless certain measures of one sort or another are taken, only one script will end up having the use of onload. There is at least one other script on your page that uses onload and it has taken onload away from the Live Date script.

    There are various solutions, for this script in this case I would suggest getting rid of (highlighted):

    Code:
    <body onLoad="goforit()">
    and then in this script add (also highlighted):

    Code:
     . . . etElementById("clock").innerHTML=cdate
    else
    document.write(cdate)
    }
    if (!document.all&&!document.getElementById)
    getthedate()
    function goforit(){
    if (document.all||document.getElementById)
    setInterval("getthedate()",1000)
    }
    
    if (window.addEventListener){
    	window.addEventListener('load', goforit, false);
    }
    else if (window.attachEvent){
    	window.attachEvent('onload', goforit);
    }
    
    </script>
    That's it!
    - John
    ________________________

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

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    egghead2000 (03-07-2010)

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
  •