473,666 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

body onunload for external links only

does anyone have sample code to display a pop up when a user leaves the
site? I really don't want to use this technique, but the clients
demand it.

I'm thinking something like un body onunload, catch the URL they're
linking to and parse it for our own site's url and only display the pop
up if they're different.

anyone have a sample of that code? anyone know if it's a lousy
technique? I'm open to suggestions.

thanks,

Don

Jul 23 '05 #1
10 4312
In article <11************ *********@c13g2 000cwb.googlegr oups.com>,
bb*****@hotmail .com wrote:
does anyone have sample code to display a pop up when a user leaves the
site? I really don't want to use this technique, but the clients
demand it.


Modern browsers do not allow a popup when you close the window.

Tell them that Windows SP2 allows the user to block pop windows.

You could implement your own close button that does a popup. Ask your
customer in a few days whether they are still using your close button or
the browser's close button.

Why does your customer want to do this? Maybe there is a more customer
friendly way of doing what they want.

I a few years back, I frequented this gaming site. They put popup
windows when I left the site. Every time you left a window, you got one
or two more. I had to reboot the pc to get out of the site. I stopped
visiting the site until I got a web browser with a popup blocker.

Robert
Jul 23 '05 #2
bb*****@hotmail .com wrote:
does anyone have sample code to display a pop up when a user leaves the
site? I really don't want to use this technique, but the clients
demand it.
Then educate your clients to the stupidity of what they want.
I'm thinking something like un body onunload, catch the URL they're
linking to and parse it for our own site's url and only display the pop
up if they're different.
How do you propose catching the URL if I type it in the address bar? You
can't.

Now, if I am on page1 of the site, and I have page14 in my favorites,
and I click the favorites (in IE) to go to that page, you have
absolutely *no* way to know where I went. Now, do I get the popup or
not? I left the "site" by not clicking a link in the page, yet I didn't
leave the site.
anyone have a sample of that code? anyone know if it's a lousy
technique? I'm open to suggestions.


It's not lousy, its stupid.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #3
yeah, I uhh... appreciate that people took the time to respond.

I made a point of explaining that I didn't want to do this, but the
clients demanded it. Functional Requirements are a negotiation.
Saying that I need to "educate" the people with the purse strings is
amateurish at best. I could educate them right out of the final check
for this work. Any developer who controls their client's requirements
is either working with low level apps or leading a charmed life.

I am writing the code based on onunload, but I do appreciate the
responses.

Don

Randy Webb wrote:
bb*****@hotmail .com wrote:
does anyone have sample code to display a pop up when a user leaves the site? I really don't want to use this technique, but the clients
demand it.
Then educate your clients to the stupidity of what they want.
I'm thinking something like un body onunload, catch the URL they're
linking to and parse it for our own site's url and only display the pop up if they're different.


How do you propose catching the URL if I type it in the address bar?

You can't.

Now, if I am on page1 of the site, and I have page14 in my favorites, and I click the favorites (in IE) to go to that page, you have
absolutely *no* way to know where I went. Now, do I get the popup or
not? I left the "site" by not clicking a link in the page, yet I didn't leave the site.
anyone have a sample of that code? anyone know if it's a lousy
technique? I'm open to suggestions.


It's not lousy, its stupid.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq


Jul 23 '05 #4
I believe that you can get this function to work in Netscape 3.x and IE
4.x.

There have been enough complaints about popups coming up from window
close, that modern browser block pops from window close.

You do want to be hired again, but a site that people do not like does
not help you.
Robert

Jul 23 '05 #5
bb*****@hotmail .com wrote:
yeah, I uhh... appreciate that people took the time to respond.
Thats what we are here for <eyeroll>
I made a point of explaining that I didn't want to do this, but the
clients demanded it. Functional Requirements are a negotiation.
You are supposed to be the professional. If you are, then it is your job
to explain the flaws in the approach and offer a better alternative.
Saying that I need to "educate" the people with the purse strings is
amateurish at best.

No, thats what makes you a professional is explaining the problems and
flaws of the approach.
I could educate them right out of the final check for this work.
Sounds like you aren't qualified to do the work.

Any developer who controls their client's requirements is either working
with low level apps or leading a charmed life.

I do not control my clients requirements, but I *do* control the
solutions. And I do not work on "low level apps" nor do I lead a charmed
life.
I am writing the code based on onunload, but I do appreciate the
responses.


Then it will ultimately fail and you will get fired for not "doing your
job", and that is probably as it should be.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Jul 23 '05 #6
What Randy says is true, you can't capture the URL in the address bar
as it is typed.

However, there is a basic "Exit Popup" script. The best solution is
not full proof. It is to write a popup script like this

var q = true;
function WaitDontLeave() {
window.open('ht tp://whatever.com');
//other popup code
}

then your onUnload attribute in the body tag will be:
onUnload="WaitD ontLeave()" the function call to your popup.

Now, the bad part is that for every href tag on the page, every form,
any tag that a visitor can click on to visit the next page in your site
must have this onClick event handler included in it.

<a href="/myfolder.nextpa ge.html" onClick="q=fals e">

Depending on the size of the site, it can be a pain. If you have a
global template, you can write a looping script to dynamically add the
onclick event handler to the tags: "a, input, ect...).

The downside is that this method, and no know method can prevent the
popups from launching if the visitor hits the BACK button, or types in
the URL from scratch, because these do not ever change the global
varialbe to false.

I have spent years in Ecommerce, and this script is used quite often
with much success. However, we usually limit it's use to just one
page, the Shopping Cart page. The thought is, if they don't move on to
the Credit Card auth page, then give them the popup with a incentive to
complete the sale. I might suggest a chat with your client about
limiting it's use to the page, or pages they most want the visitors to
take a further action on. If they don't move ahead through the normal
channels (links) then give them the popup.

Hope that was helpful.

Jeff

Jul 23 '05 #7
In the future Randy, please do not respond to my questions. They
clearly upset you by the tone you take with me.

Again, if you don't believe that requirements gathering is a
negotiation then this conversation is over. If you do, then you can
probably take the time to see where I'm coming from. If you can't take
that time, then that's your call.

Don

Jul 23 '05 #8
bb*****@hotmail .com wrote:
In the future Randy, please do not respond to my questions.
Hmmm, let me get back to you on that one.

They clearly upset you by the tone you take with me.

LOL. Usenet upset me? I want some of whatever you are smoking because
its GOOD!!!

Again, if you don't believe that requirements gathering is a
negotiation then this conversation is over.
It was over before it started. You just fail to realize the reality of
the web but that's your choice.

If you do, then you can probably take the time to see where
I'm coming from.
BTDT and learned my lesson the hard way. Looks like you will learn it
that way also. *shrug*

If you can't take that time, then that's your call.


If I didn't want to take the time, I wouldn't have bothered replying.
What you do with the information given to you is your call, not mine.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #9
Hey there... That was a bit harsh this is a completely valid approach to
perform certain things, but can be used in very irritating ways in the
wrong hands. I have used exit popups a number of times for surveys and
they work well. They catch people while the site is fresh in their minds
and can give you and your client valuable feedback on things like
usability. Overall my clients have had very few complaints from site
visitors. Follow the basic rules-
1. Ask permission
2. Tell people what you are doing
3. Don't write code that doesn't work
4. If at all possible don't do it to everyone. Sample ing a portion of
your traffic is something that you can usually sell to a client.

The best way that I have found to do this may not work for you but think
about it.

For surveys typically I opt the person into a survey group with a
request to participate in a study on entry. Their opt-in request opens
small new window (getting past popup blockers). Blur the new window to
get it out of the way. In the page that is loaded in the small window
evaluate the opener.location periodically using setTimeout to see if it
is not your site. If it is not, resizes the small window, redirect to
the page that you want to display and give it the focus.

This method obviously requires a second window to continue evaluating
the state of the opener and will need some more sophisticated logic on
sites using subdomains/multiple domains, but it does hold together on a
good swath of OS/Browser combinations.

good luck

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2208
by: Kevin Thorpe | last post by:
Does anyone know of a simple script for validating a list of external links? There are portal packages out there which do this, but I just want something simple to check links held in my database for rot. Nothing worse than giving customers 404's to make us look like wallies. I know it's relatively simple to use fopen() on each one but I really can't be bothered writing a scheduler and such. Any pointers gratefully received.
1
1871
by: Perttu Pulkkinen | last post by:
To make my system's admin page safer maybe I should apply <body onunload=""> somehow so that admin session would be reseted immediately after user closes the window? But how to check easily that unloading refers only to windowclosing, not to following links to other admin subpages?
3
1783
by: Doug Laidlaw | last post by:
I have a Web page at http://www.douglaidlaw.net/boykett/index.html which has links to three outside sources: (a) to the HTML editor, Nvu. This one works (b) to a hit counter. This shows the text in the "ALT=" tag (c) to a Web ring. This one shows nothing. I get the same results on my ISP's site and on my Apache local server, with 3 different browsers, Konqueror and Mozialla 7 under Linux and IE 6.1 under Win 98. But if I open a...
2
1201
by: Oleg Ogurok | last post by:
Hi all, Is there a way to add a client side onunload statement into the <body> tag of a page? Thanks. -Oleg.
1
2414
by: fernandezr | last post by:
I've successfully created a dynamic menu pulling data from a database however all links thus far have all been virtual urls such as /ABCD/default.aspx, /ABCD/profile.aspx, etc. Now I want to add urls that are external to my site such as http://www.rathergood.com/moon_song/ or http://www.cnn.com but when I try to use these I get "Exception Details: System.Web.HttpException: 'http://www.rathergood.com/moon_song/' is not a valid virtual...
6
1378
by: fran7 | last post by:
Hi, Can anyone point me in the direction of some asp code to record the hits to all my internal links, not my site. I have 50 external links on one page and would like to know which of the these are being visited. Thanks in advance Richard
1
2257
by: jvallee | last post by:
I have a shoping cart page wth a registration form. The submit button takes them to GoogleCheckout. I want to call my formmail.cgi with the <body unload=...> tag. However, I get 2 error messages ater I click Submit 1) cgi is undefined 2) browser prompt me to open or save cgi file
1
1201
by: chiara85 | last post by:
How can I realize an external java script page, and how can I connect it to my html page?
3
2573
by: tjtryutyu | last post by:
I know very little javascript. Nonetheless, I found some example code that opens links into a new window if they contain "external" on the "rel attribute. For example: <a href="http:example.com" rel="external">this link opens in a external window</a> I later hacked the code so it works it "nofollow" is added to the "rel" attribute like: <a href="http:example.com" rel="external nofollow">this link opens in a external window with nofollow</a> ...
0
8869
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.