i got a phpcode as ill like to have as a javascript code if anyone can help me...
Php code:

<?php 
$now_ho = date("H"); 
//Daytime(6h~19h) 
if ($now_ho < 19){ 
 if ($now_ho >= 6){ 
 $vwimg = "hh_entry_oc1"; 
 } 
} 
//Night (19h~6h) 
if ($now_ho <= 24){ 
 if ($now_ho >= 19){ 
 $vwimg = "hh_entry_oc2"; 
 } 
} 
if ($now_ho < 6){ 
 if ($now_ho >= 0){ 
 $vwimg = "hh_entry_oc2"; 
 } 
} 
?> 
cast.entry.1=<?php echo $vwimg ?>

if you dont understand the code then im looking for a code where you can show a special link at a special time in the day and an other one in the night
ex.
between 6 and 19 the link is www.whatever.com/link1
and between 19 and 6 the link is www.whatever.com/link2

Hi there,

Perhaps something like this.

<script type="text/javascript">
window.onload = function(){
    var now = new Date();
	var hour = now.getHours();
	var vwimg = "";
	if(hour < 19 & hour >= 6){						//Daytime(6h - 19h) 
		vwimg = "http://www.whatever.com/link1";
	}else if(hour <= 24 & hour >= 19){				//Night (19h - 6h) 
		vwimg = "http://www.whatever.com/link2"; 
	}else if(hour < 6 & hour >=0){
		vwimg = "http://www.whatever.com/link2";
	}
	document.getElementById("linkContainer").innerHTML="<a href='"+vwimg+"'>"+vwimg+"</a>";
}
</script>

Depending on where you'd like the link to appear you'd might want to change the last line (linkContainer) accordingly.

Regards,

Traevel

so if i wanna add it as a popup i can just do like this:

<script type="text/javascript">
window.onload = function(){
    var now = new Date();
	var hour = now.getHours();
	var vwimg = "";
	if(hour < 19 & hour >= 6){						//Daytime(6h - 19h) 
		vwimg = "<A onclick="window.open('site1',&#13;&#10;        'Loader','location=yes','resizable=yes','scrollbars=yes');return false;" href="">Loader</A>";
	}else if(hour <= 24 & hour >= 19){				//Night (19h - 6h) 
		vwimg = "<A onclick="window.open('site2',&#13;&#10;        'Loader','location=yes','resizable=yes','scrollbars=yes');return false;" href="">Loader</A>"; 
	}else if(hour < 6 & hour >=0){
		vwimg = "<A onclick="window.open('site2',&#13;&#10;        'Loader','location=yes','resizable=yes','scrollbars=yes');return false;" href="">Loader</A>";
	}
	document.getElementById("linkContainer").innerHTML="<a href='"+vwimg+"'>"+vwimg+"</a>";
}
</script>

or do i need to do that another place??

Change... document.getElementById("linkContainer").innerHTML="<a href='"+vwimg+"'>"+vwimg+"</a>"; into... document.getElementById("linkContainer").innerHTML=vwimg; And I think 'location=yes','resizable=yes','scrollbars=yes' should be 'location=yes,resizable=yes,scrollbars=yes' Although if the attributes of the popup remain the same, you could also place those at the end...

/*snip*/
else if(hour < 6 & hour >=0){
  vwimg = 'site 2';
}
document.getElementById("linkContainer").innerHTML="<A onclick=\"window.open(vwimg, 'Loader','location=yes,resizable=yes,scrollbars=yes');return false;\" href=\"\">Loader</A>";

note: not tested :$ just a quick draft :)

the problem is that i got 2 pages... my first one is day_loader.html
and the other one is night_loader.html

can you please make a fully code whit that information in...
i have no clue in how to make a javascript code

1000 x thankyou

<script type="text/javascript">
window.onload = function(){
    var now = new Date();
	var hour = now.getHours();
	var vwimg = "";
	if(hour < 19 & hour >= 6){						//Daytime(6h - 19h) 
		vwimg = "day_loader.html";
	}else if(hour <= 24 & hour >= 19){				//Night (19h - 6h) 
		vwimg = "night_loader.html";
	}else if(hour < 6 & hour >=0){
		vwimg = "night_loader.html";
	}
	document.getElementById("linkContainer").innerHTML="<a href='' onClick=\"window.open('" + vwimg + "','Loader','location=yes,resizable=yes,scrollbars=yes');\">Loader</a>";
};
</script>

Add <div id="linkContainer"></div> where you'd like the link to be.

okay to get this 100%
i add this code to my website:

<script type="text/javascript">
window.onload = function(){
    var now = new Date();
	var hour = now.getHours();
	var vwimg = "";
	if(hour < 19 & hour >= 6){						//Daytime(6h - 19h) 
		vwimg = "day_loader.html";
	}else if(hour <= 24 & hour >= 19){				//Night (19h - 6h) 
		vwimg = "night_loader.html";
	}else if(hour < 6 & hour >=0){
		vwimg = "night_loader.html";
	}
	document.getElementById("linkContainer").innerHTML="<a href='' onClick=\"window.open('" + vwimg + "','Loader','location=yes,resizable=yes,scrollbars=yes');\">Loader</a>";
};
</script>

and them i add

<div id="linkContainer"></div>

where i need the link?
am i right


sorry for all this confusion

That should work, yes :P

If the <div causes layout trouble you could always turn it into a <span by the way.

okay... thankyou VERY much for your help

edit

it just refreshes now
and there is also a { whit the link << got it fixed... it was past of the old script

opps my bad.... now it works... forgot to refresh

i need a litle more help now... AGAING

ive tryed evrything i could but i need help to add a picture to the link
the picture addrass is "/images/hotel-button-hotelopen.png" (whitout ")
and the code i got so far (still dont work) is

<a <div id="linkContainer"><IMG src="/images/hotel-button-hotelopen.png"></IMG></div></a>

i can see it arent right so plz help me (again)

<script type="text/javascript">
window.onload = function(){
    var now = new Date();
	var hour = now.getHours();
	var vwimg = "";
	if(hour < 19 & hour >= 6){						//Daytime(6h - 19h) 
		vwimg = "day_loader.html";
	}else if(hour <= 24 & hour >= 19){				//Night (19h - 6h) 
		vwimg = "night_loader.html";
	}else if(hour < 6 & hour >=0){
		vwimg = "night_loader.html";
	}
	document.getElementById("linkContainer").innerHTML="<a href='' onClick=\"window.open('" + vwimg + "','Loader','location=yes,resizable=yes,scrollbars=yes');\"><img src='/images/hotel-button-hotelopen.png' alt='"+vwimg+"'></a>";
};
</script>
<div id="linkContainer"></div>

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.