PDA

View Full Version : Only want picture to show at night.



wbsweb
11-08-2003, 11:34 AM
Hey,

I need to find a way, to make certain code appear at night, and the code dissappear in the day.

In other words.
picture.jpg only appears on my website at night time.

any suggestions?

Sualdam
11-08-2003, 01:48 PM
I found these references that might help you:

http://www.webmasterworld.com/forum21/5547-1-15.htm

http://www.scriptygoddess.com/archives/003356.php

http://www.webdevelopersnotes.com/tutorials/javascript/22.php3

wbsweb
11-08-2003, 02:41 PM
I think I should have been a little more specific.

In the day, I want to keep my site looking clean, and modest. But at night, I don't mind the traffic to see banner ads.

Here is the code I want to be valid at night.






<table width="500" border="0" cellspacing="0" cellpadding="0">

<tr>
<td><a href="http://www.BannersGoMLM.com/cgi-bin/ads/left/ads_nonssi.pl?advert=NonSSI&page=willstein.146866" target="_blank">
http://www.BannersGoMLM.com/cgi-bin/ads/left/ads_nonssi.pl?ID=bgmlm&page=willstein.146866</a></td>
<td><a href="http://www.BannersGoMLM.com/cgi-bin/ads/right/ads_nonssi.pl?advert=NonSSI&page=willstein.146866" target="_blank">
http://www.BannersGoMLM.com/cgi-bin/ads/right/ads_nonssi.pl?ID=bgmlm&page=willstein.146866</a></td>
</tr>
<tr>
<td colspan="2"><a href="http://BannersGoMLM.com/cgi-bin/ref/index.cgi?dist=willstein" target="_blank">
http://BannersGoMLM.com/images/codebottom.gif</a></td>
</tr>
</table>


<div align="left">
<SCRIPT LANGUAGE="JavaScript">
banner = '<TABLE CELLSPACING=0 CELLPADDING=0><TR><TD><A HREF="http://www.1800banners.com/cgi-bin/bpwork2.cgi?advert=NonSSI&page=44">'
banner += 'http://www.1800banners.com/cgi-bin/bpwork2.cgi?ID=willstein&page=44</a></TD>'
banner += '</TR><TR><TD>http://www.1800banners.com/logo.gif (http://www.1800banners.com)</TD></TR></TABLE>'
document.write(banner)
// -->
</SCRIPT>
<NOSCRIPT>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD>http://www.1800banners.com/cgi-bin/bpwork2.cgi?ID=willstein&page=44 (http://www.1800banners.com/cgi-bin/bpwork2.cgi?advert=NonSSI&page=44)</TD>
</TR>
<TR>
<TD>http://www.1800banners.com/logo.gif (http://www.1800banners.com)</TD>
</TR>
</TABLE>
</NOSCRIPT>
</div>
<iframe src="http://rfbe.com/iframe/?id=1793&bn=1&pg=1295" width=468 height=60 marginwidth=0 marginheight=0 scrolling=no frameborder=0>http://rfbe.com/banner/?id=1793&bn=1&bt=0&pg=1295 (http://rfbe.com/href/?id=1793&bn=1&pg=1295)</iframe>


</p>
<div align="left">
<iframe src="http://leader.linkexchange.com/X1720316/showiframe?" width=468 height=60 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no>
http://leader.linkexchange.com/X1720316/showle? (http://leader.linkexchange.com/X1720316/clickle)</iframe>


http://leader.linkexchange.com/X1720316/showlogo? (http://leader.linkexchange.com/X1720316/clicklogo)

</div>




This might be hard for a script to do, but if not, is there some sort of way to "auto upload" an html document?

Is there some program that might do it?

Thanks.

Sualdam
11-08-2003, 03:04 PM
I still think those links are relevant.

It isn't so much a case of hiding certain code until nighttime, but using a routine (like those links) which calls your code (or other code) depending on the time.

You can actually implement it in a whole number of ways. Which way will depend, for example, on how different your nighttime page is compared to the daytime one. Also, you only have direct control of the JavaScript - not the HTML - so you're going to have to think about it a bit more.

What I would do (just as an example - there are so many ways) is have an HTML page with the simple 'what time is it' code, and then redirect to either your daytime or nighttime page as appropriate. That way, the daytime/nighttime pages won't need any code to handle it at all.

wbsweb
11-08-2003, 03:14 PM
hmm that's a good idea but it wont work because this is my homepage, and that would hurt my Google PR.

I've found this code:


<script language="JavaScript">

<!-- Hide From Old Browsers

/* ©1996-98 JavaScript written by Steve Thompson @ http://www.w8r.com --- e-mail: thompson@w8r.com or myclone@hotmail.com --- This simple script changes the background image four times a day -- It can be altered to include other page attributes such as text colors and individual page items such as on the example page - Use freely but keep this entire credit line intact. */

day=new Date() //..get the date

x=day.getHours() //..get the hour

if(x>=0 && x<4) {

document.write('<body background="put your first image file name here such as 1.jpg">')

} else

if(x>=4 && x<12) {

document.write('<body background="put your second image file name here such as 2.jpg">')

} else

if(x>=12 && x<18) {

document.write('<body background="put your third image file name here such as 3.jpg">')

} else

if (x>=18 && x<24) {

document.write('<body background="put your last image file name here such as 4.jpg">')

}



</script>

and I'm wondering if anyone would know how to apply it to what I'm doing, or know any other alternatives.

Sualdam
11-08-2003, 03:28 PM
I can't see why you should affect your Google PR.

If you still want to investigate the possibility I just put this together and I think it works (it did when I changed my system time):

Click Here - link

The code for the page is (and it is very crude). Put it between the HEAD tags:

<script language="JavaScript">
<!-- Begin
function goDaytime() {
window.location = "daytime.html";
}
function goNighttime() {
window.location = "nighttime.html";
}
//-->
</script>
<script language=JavaScript><!-- Begin
day = new Date()
hr = day.getHours()
if ((hr == 1) || (hr == 2) || (hr == 3) || (hr == 4) || (hr == 5) || (hr == 6) || (hr == 7) || (hr == 8) || (hr == 21) || (hr == 22) || (hr == 23)||(hr==0))
goNighttime()
if ((hr == 9) || (hr == 10) || (hr == 11) || (hr == 12) || (hr == 13) || (hr == 14)|| (hr == 15)|| (hr == 16)|| (hr == 17)|| (hr == 18)|| (hr == 19)|| (hr == 20))
goDaytime()
// End --></script>
Note that I defined 'daytime' as after 8am until before 9pm.

wbsweb
11-08-2003, 04:05 PM
well the reason it will affect my PR is becasue the homepage would have to be the redirection script. hence, that is where the PR will be and my day/night page would be less PR. that's where the PR counts anyway.

Sualdam
11-08-2003, 04:38 PM
The principles of that code will still work.

Instead of loading a page depending on the time, load the images.

Only you know what each of your pages will look like - but if the day and night ones differ only by the presence of banners (i.e. there is blank space in the daytime one) you can easily modify the two routines 'goDaytime()' and 'goNighttime()' to show them.

If you have two completely different page layouts in mind I think you'll need to consider using PHP instead.

carbonize
11-08-2003, 10:36 PM
If you have PHP on your server then it should be relatively easy to set this up. All you need to do is decide on what times you want the banners to appear from and when you want them to stop appearing, say 6pm to 6am.

Then every time your page is called your routine will check the time and if it's later than 6pm but before 6am then it will include the HTML/XHTML for posting the banners other wise it wont.

I don't know PHP but the code would look roughly like this


<?php
if ((time<=1800)or(time<=0600))
print'BANNER HTML HERE';
?>

The real code would look nothing like that but I'm sure a PHP coder will post the correct code for it.

wbsweb
11-08-2003, 11:15 PM
that sounds like it would work.

ill make a post in the proggramming section about it.

thanks.