Results 1 to 3 of 3

Thread: Help: How to change <Body Onload=> script

  1. #1
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help: How to change <Body Onload=> script

    Hi all,

    Is there a way to change the script below from having a "onLoad="slideit()">" and move it instead to something like a window.onload thingie? Since I notice that the more body onloads I have it kinda messes up the others javascripts...

    Code:
    <script language="JavaScript1.2">
    
    
    function reapply(){
    setTimeout("slideit()",2000)
    return true
    }
    window.onerror=reapply
    </script>
    <script language="JavaScript1.1">
    <!--
    var image1=new Image()
    image1.src="images/ATS4000.jpg"
    var image2=new Image()
    image2.src="images/ATS1100.jpg"
    var image3=new Image()
    image3.src="images/ats1000.jpg"
    var image4=new Image()
    image4.src="images/icall2v.jpg"
    
    //-->
    </script>
    </HEAD>
    <BODY>
    <body onLoad="slideit()">
    Attached is the entire script (minus the jpg images)
    Thanks in advance for any help on this!

  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

    This:

    HTML Code:
    <BODY>
    <body onLoad="slideit()">
    is invalid. Just because one <body is lower case and another is upper case makes no difference, you still have two body tags. Only one is allowed. You might be able to solve your problem by changing the above to:

    HTML Code:
    <body onLoad="slideit()">
    But to answer your question, you could alternatively have this:

    Code:
    window.onload = slideit;
    in your script. Then you would be able to have just this for the opening body tag:

    HTML Code:
    <body>
    - John
    ________________________

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

  3. #3
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face It still doesnt work well with this script....

    Thanks...it worked ok, but only if its the only script running here's how I modified it btw:

    Code:
    window.onload = function reapply(){
    setTimeout("slideit()",2000)
    return true
    }
    window.onerror=reapply
    but then when combined with this script, it still wont work (this doesnt have to be put in between the <HEAD></HEAD>:
    Code:
    <script type="text/javascript">
    
    // Current Server Time script (SSI or PHP)- By JavaScriptKit.com (http://www.javascriptkit.com)
    // For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
    // This notice must stay intact for use.
    
    //Depending on whether your page supports SSI (.shtml) or PHP (.php), UNCOMMENT the line below your page supports and COMMENT the one it does not:
    //Default is that SSI method is uncommented, and PHP is commented:
    
    var currenttime = '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' //SSI method of getting server date
    //var currenttime = '<? print date("F d, Y H:i:s", time())?>' //PHP method of getting server date
    
    ///////////Stop editting here/////////////////////////////////
    
    var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
    var serverdate=new Date(currenttime)
    
    function padlength(what){
    var output=(what.toString().length==1)? "0"+what : what
    return output
    }
    
    function displaytime(){
    serverdate.setSeconds(serverdate.getSeconds()+1)
    var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear()
    var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds())
    document.getElementById("servertime").innerHTML=datestring+" "+timestring
    }
    
    window.onload=function(){
    setInterval("displaytime()", 1000)
    }
    
            </script>
    <p><b><font face="Verdana" color="FFFF00" size="2">Current Server Time:</b> <span id="servertime"></span></font></p>
    Dunno where the conflict is...

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
  •