PDA

View Full Version : easy way? popup only if first time



pjrey
10-25-2005, 11:39 PM
hi, if you goto http://pjrey.com
you will see a popup telling you about how i iwll be gone bla bla...

is there a way to have it only popup for first timers.. if you have been to my site before, it wont pop up again...
how can i do this..
im sure its very easy to do with cookies..

any help would be great

to summerise...
i want that info popup to only pop up to people who have never been to my site before, once they close it.. it will never be shown to them again...

thanks
pj

ddadmin
10-26-2005, 06:34 AM
. Also, the credit notice inside this script has been removed (not visible when view source). This is against our usage terms: http://www.dynamicdrive.com/notice.htm

pjrey
10-27-2005, 11:00 PM
ddadmin.. the credits are there! i never removed them!
they are in the JS file. i added them to the HTML to make everyone happy!

so, how can i do this with cookies?
i want it only shown if it has never been showen before...
if it has, i want nothing in its place...


thanks
pj

EDIT: aslo, is it possible to have the cookie be deleted, or reset when i modify the dropbox? if i change something, to have it reappear to the viewers...

so, view once, after that not show up again (unless the box has been modified)

thanks!!

pjrey
10-28-2005, 02:01 PM
no one knows how to do this??
hmmm

alright..
p

pjrey
10-30-2005, 10:08 PM
anybody????

ddadmin
10-31-2005, 08:40 PM
Hi:
Sorry for the delay. FYI the credit notice needs to be visible in the HTML page if the script is moved to an external .js file, so for example:

<script src="js/away_message.js">

/******************************************
* Popup Box- By Jim Silver @ jimsilver47@yahoo.com
* Visit http://www.dynamicdrive.com/ for full source code
* This notice must stay intact for use
******************************************/

</script>

To your question, to make the script pop up only once per browser session for each user, first, edit the DIV tag that contains your popup content with the below in red:

<div id="showimage" style="position:absolute;width:auto;left:300px;top:300px; z-index: 1;display: none" class="threefifths">

Then, add the below script to your page:


<script type="text/javascript">
var isloaded=0
window.onload=function(){
if (document.cookie.indexOf("isloaded")==-1){
document.getElementById("showimage").style.display="block"
document.cookie="isloaded=1"
}
}
</script>

pjrey
11-01-2005, 02:54 AM
thanks..
but when you say once per session, does mean when the browser is closed, and reopened it will show again?
i dont want this.. only if the cookies were cleared would it allow itself to be shown again.
i wish for it to be shown once, set a cookie, and then never show again, unless i change the cookie name, or the user deletes the cookie...

i dont want it showing up again for them, even if they have closed IE/FF/NN and reopened it...

thanks for getting back to me!~!
pj

pjrey
11-04-2005, 06:23 PM
does anybody know how to do this??
please help, i will be going out of town very soon... would like to figure this out before i go.. thanks. pj

ddadmin
11-04-2005, 08:43 PM
Sorry for the delay. To make the cookie feature persistent, change the script I posted above to:



<script type="text/javascript">
var isloaded=0
window.onload=function(){
if (document.cookie.indexOf("isloaded")==-1){
document.getElementById("showimage").style.display="block"
var expireDate = new Date()
expireDate.setDate(expireDate.getDate()+100)
document.cookie = "isloaded=1; path=/;expires=" + expireDate.toGMTString()
document.cookie="isloaded=1"
}
}
</script>


This will cause the pop up to only do so once 100 days, which should be long enough in most cases.

pjrey
11-04-2005, 09:40 PM
thanks again for your help.
but is it possible to just have it change when i update it? (i could rename the cookie...?)
i am not familiar with cookies one bit, as you can surely tell!

thanks ddadmin

pj

EDIT:
i just tried it out.. no goo... when i close my browser and try again it pops right back up... with EI and FF...
i want this to be gone for good... unless i rename/edit the contents

thanks

pjrey
11-09-2005, 07:50 PM
so i take it, this cant be done.. does anyone know how to write cookies? i havent a clue...

please help
thanks

ddadmin
11-09-2005, 09:00 PM
Hi pjrey:
It's more difficult to get the cookie to automatically reset when the popup content has been changed, but the basic version of the popup only showing up once should work based on what I've posted above. Or does even that not work for you? Something you said seemed to indicate so:


EDIT:
i just tried it out.. no goo... when i close my browser and try again it pops right back up... with EI and FF...
i want this to be gone for good... unless i rename/edit the contents

pjrey
11-10-2005, 12:15 AM
no, its not working... when i open the browser again, it pops up again... then i hit the X, close it, reload, it doesnt show up again, good. then i CLOSE my BROWSER (FF, NN, IE) and goto pjrey.com and there it is again, popped up again...

its not remembering...

p

Wedgy
11-18-2005, 08:25 PM
I found this script. I don't know if it can help:

First Visit PopUp WIndow

Place the following code within the <BODY> of your web page.
<SCRIPT LANGUAGE="JavaScript">
<!-- Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development
function GetCookie(name) {
var arg=name+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen) {
var j=i+alen;
if (document.cookie.substring(i,j)==arg)
return "here";
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;
}
return null;
}
var visit=GetCookie("COOKIE1");
if (visit==null){
var expire=new Date();
window.name = "thiswin";
newwin=open("yourpagename.html", "dispwin",
"width=450,height=455,scrollbars=yes,menubar=no");
expire=new Date(expire.getTime()+7776000000);
document.cookie="COOKIE1=here; expires="+expire;
}
// -->
</SCRIPT>

Replace the words "yourpagename.html" with your popup window address
and edit the window's width and height to your desired size.


Script courtesy of Brian Terry http://www.secretwebriches.com
"Turn this key to unlock your dreams!"