It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

pop up

pop up

Postby ravindralokhande on Sat Jan 05, 2008 11:55 am

i want to display a new pop up on window close. The problem i am facing is that when user refreshes page instead of closing it then also that pop up comes up.

code i have written:

<head>
<script language="javascript">
function abc()
{
window.open('a.html');
}
</script>
</head>
<body onunload=abc()>
</body>
ravindralokhande
 
Posts: 0
Joined: Sat Jan 05, 2008 11:50 am

Postby leonard on Mon Jan 07, 2008 2:01 pm

I don't think this can be done with plain HTML/JavaScript, not even using cookies.

The problem is the refresh-button triggers the onunload function. Using cookies you could trigger the refresh-button and not trigger the full-exit (but not the other way round).

I think this would have to be done with external browser components (applet/flash?), but anyway a popup onunload is a very nasty thing, because normally a user wants to fully exit a page when he closes the window. This code is somehow an equivilant to spam-mails and not that of a user-friendly site.
Anyway, popups are blocked in the most browsers (which is good). There is therefore no way to guarantee the popup will really be displayed.

If you find a way to do this, please paste it here, I would be interested (even if I don't agree with the use of popups on window-close).

cheers!
- leonard
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland


Who is online

Users browsing this forum: No registered users and 2 guests