473,651 Members | 3,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exit code for a html page

We have a website we need to open popup under following conditions
1) When user close the browser either via X button or alt + f4, file ->
Close
2) when he changes URL and goes to some other site.

3) but it should not open the popup window till the user is on same
website.

we have tried lot of combinations but till date nothing there.

We look forward for your help to resolve this issue.
this is now becoming big for us and for our client
thanks
Parminder
Connoisseur Infotech Pvt. Ltd.
<a href="http://www.econnoisseu r.com" target="_blank" > Complete web
development and web designing company http://www.econnoisseur.com/
</a>

Jul 23 '05 #1
9 13576
co************* *****@gmail.com wrote:
We have a website we need to open popup under following conditions
1) When user close the browser either via X button or alt + f4, file ->
Close
2) when he changes URL and goes to some other site.

3) but it should not open the popup window till the user is on same
website.

we have tried lot of combinations but till date nothing there.

We look forward for your help to resolve this issue.
this is now becoming big for us and for our client
thanks
Parminder
Connoisseur Infotech Pvt. Ltd.
<a href="http://www.econnoisseu r.com" target="_blank" > Complete web
development and web designing company http://www.econnoisseur.com/
</a>


You may use the unload event to open the popup. When a page gets loaded,
step through all links and add a javascript click handler which will set
a global variable. Check for that variable in your unload handler. If it
is not present, show the popup.

Daniel

Fup 2 comp.lang.javas cript
Jul 23 '05 #2
"Daniel Kirsch" <Iw************ *****@gmx.de> kirjoitti
viestissä:d8*** **********@news .t-online.com...
co************* *****@gmail.com wrote:
We have a website we need to open popup under following conditions
1) When user close the browser either via X button or alt + f4, file ->
Close
2) when he changes URL and goes to some other site.

3) but it should not open the popup window till the user is on same
website.

we have tried lot of combinations but till date nothing there.

We look forward for your help to resolve this issue.
this is now becoming big for us and for our client
thanks
Parminder
Connoisseur Infotech Pvt. Ltd.
<a href="http://www.econnoisseu r.com" target="_blank" > Complete web
development and web designing company http://www.econnoisseur.com/
</a>


You may use the unload event to open the popup. When a page gets loaded,
step through all links and add a javascript click handler which will set a
global variable. Check for that variable in your unload handler. If it is
not present, show the popup.


Problem there is that it would pop up constantly when switching pages inside
the same website. At least that's how I understood it. Meaning if I have two
pages, named A and B under domain www.my_stupid_domain.com, when I clicka
link on page A that leads me to B, no pop up is shown. When I move from B
back to A no popup is presented either. When I close the browser, then and
only then the pop up appears. If that is in fact the requirements, I see a
potentially terrible terrible solution - but it might work. Make a frame
container that has two frames, which has rows 100% and *. Inside the 100%
frame you have the pages. When you move from one page to another inside the
frame, nothing happens. Now, in the invisible * frame you have nothing
except this:
<html><body onUnload="show_ the_damn_popup( );"></body></html>. When you close
the browser, or move to another location (ie. when the frame is closed.),
the bottom frame is exited, thus onUnload is triggered.

I know it is completely pointless to tell that what you are doing there is
once again hating your clients so much that you wish to irritate them with a
pop up, and I for one would not approve such behaviour on my site. But
people are willing to do so much to drive their clients away from crappy web
sites, I'm not at all surprised you want to do this, so a possibly working
solution is suggested above. Feel free to use it.

Did you know that when one little panda makes a pop up window attack another
little pandas browser, that's hypertextual harrasment. And that makes me a
saaad panda...
(Disclaimer: If you haven't watched South Park, ignore that, you won't get
it.)

--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears

et************* ***@5P4Mgmail.c om
Jul 23 '05 #3
Kimmo Laine wrote:
Problem there is that it would pop up constantly when switching pages inside
the same website.


No:
"When a page gets loaded, step through all links and add a javascript
click handler which will set a global variable. Check for that variable
in your unload handler. If it is not present, show the popup."

var internalLink = false;

onload = function() {
var links = document.links;
for (var i=0; i<links.length ; i++) {
links[i].onclick = function() {
internalLink = true;
location.href = this.href;
return false;
}
}
};

onunload = function() {
if (!internalLink)
showPopup();
};

Daniel
Jul 23 '05 #4
Daniel Kirsch wrote:
co************* *****@gmail.com wrote:
We have a website we need to open popup under following conditions
1) When user close the browser
2) when he changes URL and goes to some other site.
You may use the unload event to open the popup. When a page gets loaded,
step through all links and add a javascript click handler which will set
a global variable. Check for that variable in your unload handler. If it
is not present, show the popup.


Thankfully most browsers now have popup blockers, so many users won't suffer
the popup.

--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #5
"Daniel Kirsch" <Iw************ *****@gmx.de> kirjoitti
viestissä:d8*** **********@news .t-online.com...
Kimmo Laine wrote:
Problem there is that it would pop up constantly when switching pages
inside the same website.


No:
"When a page gets loaded, step through all links and add a javascript
click handler which will set a global variable. Check for that variable in
your unload handler. If it is not present, show the popup."

var internalLink = false;

onload = function() {
var links = document.links;
for (var i=0; i<links.length ; i++) {
links[i].onclick = function() {
internalLink = true;
location.href = this.href;
return false;
}
}
};

onunload = function() {
if (!internalLink)
showPopup();
};


I must be from Slowvill or something. Hadda read that like ten times before
I understood what it does exactly, but it does make sense. However:

links[i].onclick = function() {
internalLink = true;
location.href = this.href; // are these
return false; // really necessary??
}

wouldn't be just the same:

links[i].onclick = function() {
internalLink = true;
}

The link does that just the same if you return true, or don't return
anything. The only thing the onClick funtion needs to do is set internalLink
true and let the link do the rest, as it would do anyway...

Anyway, it's much better solution than what I suggested, as it utilizes no
frames. Still, that sort of functionality on a website uses the dark side of
javascript if you ask me.

--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears

et************* ***@5P4Mgmail.c om
Jul 23 '05 #6
David Dorward wrote:
Thankfully most browsers now have popup blockers, so many users won't suffer
the popup.


Most of these blockers allow popups on a user interaction like a click.
Some of them are customizable enough to change that too.

Daniel
Jul 23 '05 #7
Kimmo Laine wrote:
The link does that just the same if you return true, or don't return
anything. The only thing the onClick funtion needs to do is set internalLink
true and let the link do the rest, as it would do anyway...


You're probably right :-)

Daniel
Jul 23 '05 #8
Daniel Kirsch wrote:
David Dorward wrote:
Thankfully most browsers now have popup blockers, so many users won't
suffer
the popup.

Most of these blockers allow popups on a user interaction like a click.
Some of them are customizable enough to change that too.


You are not opening the popup onclick of the link, you are opening (or
attempting to) open it onUnload of the page. Popup blockers block those
popups because they are unrequested. That is, unless you think that
leaving your site is requesting that you bombard me with popups. Why do
you think popup blockers are so popular??

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #9

"Randy Webb" <Hi************ @aol.com> wrote in message
news:iq******** ************@co mcast.com...
Daniel Kirsch wrote:
David Dorward wrote:
Thankfully most browsers now have popup blockers, so many users won't
suffer
the popup.

Most of these blockers allow popups on a user interaction like a click.
Some of them are customizable enough to change that too.


You are not opening the popup onclick of the link, you are opening (or
attempting to) open it onUnload of the page. Popup blockers block those
popups because they are unrequested. That is, unless you think that
leaving your site is requesting that you bombard me with popups. Why do
you think popup blockers are so popular??


Personally, I would fire a client who insisted that I do something like
that, unless they could demonstrate a VERY valid reason.

Thus far, I haven't been able to come up with such a reason...
Jul 23 '05 #10

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

Similar topics

7
4777
by: Alex Hunsley | last post by:
I'm making a web site that does login authentication. It all works fine, but I have a question about 'correctness'... Certain php scripts on the site should only run in the user has logged on. So, the 'private' scripts in question all includes the following php script: <? // has user authenticated? if (! $logged_in) {
3
10379
by: Alex Shi | last post by:
Hello, I need an Exit popup page that when a visitor is on leaving my site it will popup. With "onUnLoad" it can work in this way but it also does something more that I don't want. When a visitor click links to pages within my site the popup will also open. I don't want this. What I need is that only when a visitor is leaving my site but current page, the popup will open. Anyone have a solution for this please give me a hand. Thanks in...
4
28557
by: highway of diamonds | last post by:
a bit of a 'hacker' with javascript but can any one tell me why this code throws up "'exit' is undefined" and how to sort. the code does what I want it to, but hate errors I can't explain. TIA R. code is:
3
7439
by: Robb Gilmore | last post by:
Hi, We have an ASP.NET web application that attempts to check some database conditions in Application_start to ensure that all is well before the app comes up. However, I figure out how to force the app to exit if this verification fails. Just throwing an exception doesn't seem to do the trick. The app still comes up. I feel like I should be able to call Application.exit() inside of Application_start, but of course there is no such...
8
3734
by: Atanas Banov | last post by:
i ran onto this weirdness today: seems like close() on popen-ed (pseudo)file fails miserably with exception instead of returning exit code, when said exit code is -1. here is the simplest example (under Windows): >>> print popen('exit 1').close() 1 >>> print popen('exit -1').close() Traceback (most recent call last):
11
2448
by: yawnmoth | last post by:
To quote from <http://php.net/function.include>, "Because include() is a special language construct, parentheses are not needed around its argument. Take care when comparing return value." exit is a language construct, also. To quote from <http://php.net/ function.exit>, "this is a language construct"
5
1523
by: vijay | last post by:
Is there a way using javascript (or anything else) to know where the users go after they leave my page? Like "Do you want to navigate away ..." does a good job of alerting people no matter how they want to navigate away, clicking on links, clicking on bookmarks, typing new URLs etc, can I know where they go when they exit my page?
3
2565
by: Tim Roberts | last post by:
JRough <jlrough@yahoo.comwrote: More than the syntax problems, you also have a logic problem here. How do you think that "if" statement is ever going to be hit, given the statement immediately before it? -- Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc.
39
2796
by: mathieu | last post by:
Hi there, I am trying to reuse a piece of code that was designed as an application. The code is covered with 'exit' calls. I would like to reuse it as a library. For that I renamed the 'main' function into 'mymain', but I am stuck as to what I should do for the 'exit'. AFAIK there is no portable way to catch the exit. The only thing I can think of is atexit, but that does not work since 'exit' is still called afterward.
0
8361
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8278
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8584
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
7299
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...
0
5615
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
4144
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
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
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

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.