PDA

View Full Version : DHTML Window widget: Pop up once per browser session only?



sajr
05-10-2007, 07:09 PM
Script: http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm (added by ddadmin this time).

I am trying to make a website for the staff at a school, and it can only be accessed locally - it's not posted on the web. I used the "DHTML Window widget" from this site to make a pup-up when you open the home page, so it shows pictures when ever the staff open the site. The problem is - it can get annoying when it opens this image every time you go back to the home page. For a demonstration, go to Windows and Frames on Dynamic Driva, and click on DHTML Modal window. Try clicking back and forward - it just takes time, when the staff could just disable it not to show until the next day, or until the browser is closed and then reload the next time the browser opens. Does anyone know how this can be made? I'm new to DHTML and JavaScript, so I can't come up with something myself. If anyone can help me, that would be appreciated. I need this ASAP.

ddadmin
05-10-2007, 09:48 PM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

Try the below modified dhtmlwindow.js file instead, which adds support for session only persistence, so you can set a window to only pop up once per browser session. This is realized by a new optional parameter at the very end of dhtmlwindow.open(). Whereas before you had something like:


var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://images.google.com/", "#1: Google Web site", "width=590px,height=350px,resize=0,scrolling=1,center=1", "recal")

To get this window to only pop up once per browser session, throw in a new parameter at the very end:


var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://images.google.com/", "#1: Google Web site", "width=590px,height=350px,resize=0,scrolling=1,center=1", "recal", "sessiononly")

I'll be adding cookie support to this script formally the next time it's updated.

sajr
05-14-2007, 06:55 PM
Thanks, but unfortunately this site is not on a server, so we can't use cookies. I'll probably end up just creating a link that opens this pop-up, unless somebody suggests a better option. Thanks again for your time.

ddadmin
05-14-2007, 08:39 PM
Well, these are client side cookies, meaning they are stored in the visitor's browser...

xpgo
05-26-2007, 07:20 PM
Hello,

I'm also trying to use "DHTML Window widget (v1.03)".
I would like to have this opened every X pages.
How can i set this, instead of having it opened everytime a page is opened?

Thanks

djr33
05-26-2007, 07:48 PM
Show it if there is no cookie (first time), then create a cookie with the number "5" as its value. On each page, check for that cookie and:
1. If no cookie, see above.
2. If value over 1, set the cookie to its value-1, so the first time 4, then 3, etc.
3. If the value is 1, then clear the cookie.

Or, if preferable, you could (3) set the cookie to 0, then, if value is 0, do (1).

Guinness
08-30-2007, 09:08 PM
Greetings,

I am trying to do something similar with this script and since I'm pretty much a noob at this stuff I wonder if somebody could help me.

I would like to load this dhtml window once when a users logs in to an intranet page. I know on the page whether or not I want to display the popup window but I don't know how to trigger it.

In other words, say i wanted the window to launch if the day is Tuesday. On the page I know if it's Tuesday but don't know how to "trigger" the window. Any other day of the week the window would not open.

Thanks-

SteveMc
08-30-2007, 11:38 PM
I am just doing a quick post and maybe this will help. I never send users off to another website directly. It's a best-practice to have a redirect page in PHP, ASP or whatever, that is the popup window target with the URL as a parameter. Then in the redirect.XXX you 301 redirect to where ever you want to send them. If you want you can add some SQL and save any server or QS values you want.

--Steve

aris1234
01-20-2008, 11:45 AM
Has this mod been rolled into the latest version of the script? Looking at it, it appears not.

Thanks,

ddadmin
01-20-2008, 02:50 PM
Sure, attached is dhtmlwindow.js (v1.1), modified like above to include the optional "sessiononly" only variable when opening a DHTML window, so it only opens once per browser session.

aris1234
01-20-2008, 04:32 PM
Are you sure it is in there? If I look at the code you posted in this thread originally, there are all sorts of references to 'session' while the 1.1 code does not have this. Apologies in advance if i'm being stupid here :)

ddadmin
01-20-2008, 06:55 PM
Look closer! :D Actually you're right, attached the wrong version. I've corrected the attachment in that post.

aris1234
01-20-2008, 07:32 PM
Aha - that's it - thanks :)

Now a feature request - an option to have it only show every X page loads, or perhaps an option to have it stop showing after the user presses a 'don't show this again' button. So when they press the button, it sets the cookie, but if not, then it doesn't and it keeps showing.

Just an idea... :-)

Ross2452
03-26-2008, 02:18 PM
i may be being really stupid but i still cant get it to work :(

been fiddleing with it for hours now...:(

If someone more talented than me would be kind enough to take a look.....
Link to directory with js (http://www.scottishgraduate.com/POPUP/windowfiles/)

page that the popup should appear on. (http://www.scottishgraduate.com/POPUP/indy.htm)

The window appears but it dosent seen phased by the session controls? it just keeps popping up :(

any ideas would be much appreciated.....i give in!!

powerful_rogue
05-19-2009, 03:14 PM
Hi,
Im new to javascript and was wondering if someone would be able to help.

Ive got this script installed on my forum and its working fine, however im having some issues with the cookies. Where abouts in the dhtmlwindow.js do I set how long to store the cookie for?

Also, I was wondering if there would be any simple way to link it up to a database, so a user has to dismiss a popup to stop it showing. Once its been dismissed that popup wont show again to the same member. (Similar to this (http://dbachrach.com/blog/2007/04/23/simple-dismissal-notifications-in-javascript/) but in popup form)

Also an option to allow different popups to be created.

EG -
Popup1 - Hello Member
Once dismissed wont show agaon

Popup2 - How are you?
Once dismissed wont show again

Popup3 - Good to see you
Once dismissed wont show again

Im presuming it will have to be based around an userid or similar

Any help greatly appreciated :)

nzguy1
10-07-2009, 05:42 AM
Hi

I'm new to the forum so please forgive me if I have missed something.

I used the new version of dhtmlwindow.js with the "sessiononly" modifier and this works fine in Firefox, Chrome and Safari. It also works in IE7 if the link is to an html file but not if it is to a PDF file. Here, the default IE7 setting blocks the PDF download and when you click the information line to allow the download, the widget window disappears and the initiating page reloads.

If the "sessiononly" modifier is removed, then the PDF download continues correctly after the information line is clicked but, of course, the widget reloads every time the initiating page is reloaded.

Unfortunately the obvious solution of ditching IE is not possible as the site will mainly be viewed by IE users.

Can anybody suggest anything else?

EdgarRomero
03-31-2011, 10:18 AM
hey there, first of all i'm new in the forum.. i woul like to thanks DD for all the script, i'm starting in the world of web design..

So i had a problem, just like wrote the SAJR i would like to know how to make this popup appears once per browser, i tried to do all you have wrote in this topic but doesn't work...

_____________________________
Script: Interstitial Content Box (v1.1)
[URL="http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/dhtmlmodal.htm[/URL]
_____________________________

I'll apreciate the help

EdgarRomero
03-31-2011, 10:22 AM
in what number of line i should modify the dhtmlwindow.js file to get the popup just once per session?