PDA

View Full Version : Help: How to change <Body Onload=> script



serenedipity
06-05-2008, 08:24 PM
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...:confused:


<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):p
Thanks in advance for any help on this!

jscheuer1
06-05-2008, 11:50 PM
This:



<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:


<body onLoad="slideit()">

But to answer your question, you could alternatively have this:


window.onload = slideit;

in your script. Then you would be able to have just this for the opening body tag:


<body>

serenedipity
06-07-2008, 07:13 PM
Thanks...it worked ok, but only if its the only script running:( here's how I modified it btw:


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>:

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