PHP popup on exit

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
mattmcb
Forum Commoner
Posts: 27
Joined: Sun Jan 25, 2004 3:34 pm

PHP popup on exit

Post by mattmcb »

Does anyone know of a way to use php instead of javascript to display a popup window on exit, a true exit and not just an unload or beforeunload?

Is there a way to keep the current window open, display the popup, when the user wants to exit?

The concept is to display a popup window with a discount coupon when someone exits the checkout, hopefully keeping them from leaving your site during checkout!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it'd all be controlled client-side, so I'm pretty sure there is no way to know exactly when they really leave the site.
brandan
Forum Commoner
Posts: 37
Joined: Sat Jul 24, 2004 6:39 pm
Location: fort smith, ar

Post by brandan »

php is a markup scripting language that is interpreted by the server, not the client.

or it used to be.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

or it used to be.
still is
brandan
Forum Commoner
Posts: 37
Joined: Sat Jul 24, 2004 6:39 pm
Location: fort smith, ar

Post by brandan »

i added that in because i just didn't know.
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

you would need to use the js onUnload function to open an new window with the coupon...
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

to elaborate:

Code: Select all

SCRIPT LANGUAGE="JavaScript">
function openwin() {
  window.open("coupon.html", "title", "toolbar=0,status=0,menubar=0,scrollbars=no,resizable=no,width=315,height=400");
&#125;</SCRIPT>


Code: Select all

<body bgcolor="000000" onUnload="openwin()">
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

As i user i hate this kinda thing though. I leave a web page as i WANT to leave and dont want to be swamped with pop-ups..... i just want to leave the site. Just a word of warning.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

i will agree 110% with above.

If I can get my mouse over to the close button fast enough, the pop-ups never load.

and if they do, i dont pay any attention to them.
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

Oh cmon guys I LOVE pop-ups, especially the porn ones, you know they just pop up whwenever you start firefox and guess what YOUR MOM passing by and GUESS WHAT these, let's call em APTCDFH (wich means Awesome Pop-up That Come Directly From Hell), have features like SOUND and ANIMATION. It is really AWESOME. Please anyone who wants to make pop-up when I LEAVE a site is like woah dude,your are given a whole new meaning to APTCDFH. I just installed on my computer lately a programm that just randomly pop-up something on my computer. It's so cool.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

tim wrote:to elaborate:

Code: Select all

SCRIPT LANGUAGE="JavaScript">
function openwin() &#123;
  window.open("coupon.html", "title", "toolbar=0,status=0,menubar=0,scrollbars=no,resizable=no,width=315,height=400");
&#125;</SCRIPT>


Code: Select all

<body bgcolor="000000" onUnload="openwin()">
That wouldn't work as intended because the onUnload function is also executed when the users browses from one page of the site to another, not just when they close the window!

To get the desired affect, you need to use frames!

I have described how to do this a few time on this forum, do a search.

mark
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

Well, you could adapt the JS to see what page the its going to is...ie capturing the url...then popup if url is not in your site or the closes the browser...

Draco, love the APTCDFH, trouble is I keep spitting on my co-workers trying to pronounce it...:)
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post by Draco_03 »

Hahahahaha...
yeah hehe it's quite impossible.. :P
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

lostboy wrote:Well, you could adapt the JS to see what page the its going to is...ie capturing the url...then popup if url is not in your site or the closes the browser...

Draco, love the APTCDFH, trouble is I keep spitting on my co-workers trying to pronounce it...:)
Far easier to have you site in frames.

One which is only something like 1px in height. Load a page into there with the onUnload function, then, load the rest of yor site into the other frame.

Result: pop-up window will only appear when closing the browser window!

Easy!!

Mark
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

I agree, I was just offering another framless option, thats all
Post Reply