andysim
02-19-2012, 05:49 PM
Hi, hope someone can help!
Got this script that changes an image on my website but i can not get it to change the image more than twice..
function pixTimeChange() {
var t=new Date();
var h = t.getHours();
var r1="http://www.site.com/maxsite/ShowChange_Images/Change7a.png";
var r2="http://www.site.com/ShowChange_Images/Change7b.png";
var el=document.getElementById('myimage');
//I need to add more time changes, but it will not let me.. HELP
// See the time below. Note: The time is in 24 hour format.
// In the example here, "7" = 7 AM; "17" =5PM.
el.src = (h>=7 && h<17) ? r1 : r2;
}
I have some other code:
// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() { . . .
It works with this code (php?)
<script language="JavaScript1.2" type="text/javascript">
//Daily iframe content- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, and Terms Of use, visit http://dynamicdrive.com
//This credit MUST stay intact for use
var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1
var iframeprops='width=150 height=490 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"'
var daycontent=new Array()
daycontent[1]="http://www.site/date1.php"
daycontent[2]="http://www.site.com/date2.php"
daycontent[3]="http://www.site.com/date3.php"
daycontent[4]="http://www.site.com/date4.php"
daycontent[5]="http://www.site.com/date5.php"
daycontent[6]="http://www.site.com/date6.php"
daycontent[0]="http://www.site.com/date7.php"
if (ie||dom)
document.write('<iframe id="dynstuff" src="" '+iframeprops+'></iframe>')
var mydate=new Date()
var mytoday=mydate.getDay()
function dayofweek_iframe(){
if (ie||dom){
var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
iframeobj.src=daycontent[mytoday]
}
}
window.onload=dayofweek_iframe
</script>
Hope you understand what i am trying to do?
Cheers
Andy
Got this script that changes an image on my website but i can not get it to change the image more than twice..
function pixTimeChange() {
var t=new Date();
var h = t.getHours();
var r1="http://www.site.com/maxsite/ShowChange_Images/Change7a.png";
var r2="http://www.site.com/ShowChange_Images/Change7b.png";
var el=document.getElementById('myimage');
//I need to add more time changes, but it will not let me.. HELP
// See the time below. Note: The time is in 24 hour format.
// In the example here, "7" = 7 AM; "17" =5PM.
el.src = (h>=7 && h<17) ? r1 : r2;
}
I have some other code:
// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() { . . .
It works with this code (php?)
<script language="JavaScript1.2" type="text/javascript">
//Daily iframe content- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, and Terms Of use, visit http://dynamicdrive.com
//This credit MUST stay intact for use
var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1
var iframeprops='width=150 height=490 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"'
var daycontent=new Array()
daycontent[1]="http://www.site/date1.php"
daycontent[2]="http://www.site.com/date2.php"
daycontent[3]="http://www.site.com/date3.php"
daycontent[4]="http://www.site.com/date4.php"
daycontent[5]="http://www.site.com/date5.php"
daycontent[6]="http://www.site.com/date6.php"
daycontent[0]="http://www.site.com/date7.php"
if (ie||dom)
document.write('<iframe id="dynstuff" src="" '+iframeprops+'></iframe>')
var mydate=new Date()
var mytoday=mydate.getDay()
function dayofweek_iframe(){
if (ie||dom){
var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
iframeobj.src=daycontent[mytoday]
}
}
window.onload=dayofweek_iframe
</script>
Hope you understand what i am trying to do?
Cheers
Andy