Click to See Complete Forum and Search --> : Cookies/Display Once Javacode?? Please Help!!!
viperspit01
06-04-2003, 08:57 PM
Hi,
I am a rookie at javascript and I was wondering if any java programmers can tell me how I would call a script once, and then the script wont be called again if the visitor visits the same page in 24 hours using javascript and cookies, I know this is possible but all i have found is giant javascripts, and ones that you have to put into your <head> tags etc.
This is the script i would call as an example:
<script type="text/javascript" src="http://www.yoursite.com/cgi-bin/test/ad_test.cgi"></script>
Now i have found avery good java code that will call a script once every 24 hours:
<!-- Begin Ad Display Once Pop Up Code -->
<script language=JavaScript type=text/javascript>
<!--
if(get_cookie('popup')==''){var popUpWindow=window.open("http://www.yoursite.com/cgi-bin/ads/advert.cgi?zone_id=4&mode=popup","popup","width=0,height=0");document.cookie="popup=yes";}
function get_cookie(name){var search=name+"=";var returnvalue="";if(document.cookie.length>0){offset=document.cookie.indexOf(search);if(offset!=-1){offset+=search.length;end=document.cookie.indexOf(";",offset);if(end==-1){end=document.cookie.length;returnvalue=unescape(document.cookie.substring(offset,end));}}}return returnvalue;}
//-->
</script>
<!-- End Ad Display Once Pop Up Code -->
but unfortunetly its a popup code....is there any sugesstions out there?? I would really, really appreciate some help as i am a rookie at Javascript.
Thanks.
Khalid Ali
06-04-2003, 09:04 PM
You might want to take a look at this script
http://68.145.35.86/skills/javascripts/SimpleLoginCookieScript.html
viperspit01
06-04-2003, 09:12 PM
hi,
Thanks for that quikc response Khalid Ali, but i dont think i can use that script...its too hard to configure....surely there must be a simpler javascript code, because i have seen them for popups, but i just cant find one that will just call the code once every 24 hours etc..i have looked everywhere seriously...but with no luck, i have seen all these diaply once javascript popups which are relatively simple...so how come there isnt just a standard one for calling a non popup code??
Is it possible to edit/debug this popup code?:
<!-- Begin Ad Display Once Pop Up Code -->
<script language=JavaScript type=text/javascript>
<!--
if(get_cookie('popup')==''){var popUpWindow=window.open("http://www.yoursite.com/cgi-bin/ads/advert.cgi?zone_id=4&mode=popup","popup","width=0,height=0");document.cookie="popup=yes";}
function get_cookie(name){var search=name+"=";var returnvalue="";if(document.cookie.length>0){offset=document.cookie.indexOf(search);if(offset!=-1){offset+=search.length;end=document.cookie.indexOf(";",offset);if(end==-1){end=document.cookie.length;returnvalue=unescape(document.cookie.substring(offset,end));}}}return returnvalue;}
//-->
</script>
<!-- End Ad Display Once Pop Up Code -->
Thanks so much!! please help me!
Khalid Ali
06-04-2003, 09:21 PM
do you want to put any conditions?
at all...like person enters name and stuff at the first time...and the second time and after the first time it will not open the popup...????
viperspit01
06-04-2003, 09:36 PM
nah sorry, your confused...and thats my fault! i should have explained it more! here is a summary of what i need it for:
The reason i need this is for an advert script, it works by calling up this <script type="text/javascript" src="http://www.yoursite.com/cgi-bin/test/ad_test.cgi"></script> and the the ad_test.cgi contains an ad code which will obviously be displayed on the page, now what i am after is a javascript code that will call up this script once per 24 hour visit....i know there are ad programs our there but i dont want to use them, and are just experimeting....so is there a script but, that will just run with all bowsers, that will execute the script, but only once per 24 hours visit to the site?? i have seen many popup codes that can do this, but all i need is a javascript xode that will do the same, as in execute the script once per 24 hour visit.
thanks buddy:)
brendandonhue
06-05-2003, 06:29 AM
It can be done-but you should use serverside code for this.
If you use JS, your advertising won't work for about 13% of users.
viperspit01
06-05-2003, 06:54 AM
why wont they see it?? because of there browser?
and if it can be done then whats the javascript code?
can anyone provide the javascript code? please!!
Khalid Ali
06-05-2003, 08:46 AM
The link I provided you way aboe in this thread does exactly the same.it gives a message for the first time when user comes on line,then there are comments in the code to how to make this message appear in a certain time period.
tthe "Only " thing you had to do was change the time from 1 minute(in the existing code) to 24 hour and instead of prompt put your javascript code the be run....The forum is for helping people in guiding to their solution....Can't believe how they expect that people here "have" to provide a complete "working" solution.
viperspit01
06-05-2003, 08:50 AM
i dont expect people to have to provide the code, i merely ask that if someone has a code to share it with the community and not be so fu**king selfish and keep it to themselves...
i will check out the code again.
thanks.
Khalid Ali
06-05-2003, 09:12 AM
quote:Originally posted by viperspit01
inot be so fu**king selfish and keep it to themselves...
This forum is for helping people in completing teir programming task( javascript etc...)
you may want to be nice to people to get help,otherwise people do remember who they was mean or rude and you might nit get any responses at all to your post or worse your privilige to post a message here could be revoked and your account might end up in cancellation
__________________
keteracel
06-05-2003, 06:49 PM
Putting the pieces together we should get this:
<!-- Begin Ad Display Once Pop Up Code -->
<script language=JavaScript type=text/javascript>
<!--
if(get_cookie('popup')==''){
document.write('<script type="text/javascript" src="http://www.yoursite.com/cgi-bin/test/ad_test.cgi"></script>');
document.cookie="popup=yes";
}
function get_cookie(name){
var search=name+"=";
var returnvalue="";
if(document.cookie.length>0){
offset=document.cookie.indexOf(search);
if(offset!=-1){
offset+=search.length;
end=document.cookie.indexOf(";",offset);
if(end==-1){
end=document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset,end));
}
}
}
return returnvalue;
}
//-->
</script>
<!-- End Ad Display Once Pop Up Code -->
Simply place this code where you want the ad script to be included.
hope this helps...
keteracel (http://www.keteracel.com)
viperspit01
06-05-2003, 09:32 PM
hi, thanks for trying to help, but i get the java-script error when i try and run this code..is there any think i can do? i have tried to edit the script but to no avail, becuase i am a rookie!
And wouldnt this code still produce a popup but??
thankyou so much keteracel hope to hear from you soon!
thanks.