The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

2 Pages V  1 2 >  
Reply to this topicStart new topic
> Redirect into new tab, Redirection
americast but from India
post Aug 1 2012, 04:56 AM
Post #1


Newbie
*

Group: Members
Posts: 12
Joined: 1-August 12
Member No.: 17,530



I want my users to go to another website when they close my website. So, I used the given code but I cannot understand what is wrong in it. Please help. Thanx for any help...

[code]
<script type="text/javascript">

window.onunload = unloadPage;

function unloadPage()
{
window.open("exampleurl","_blank")
}
</script>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 1 2012, 07:17 AM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



What happens now? Nothing or does it open a new window? What browser(s)?

I don't think you should have "_blank" there. If you want to name the window, choose your own name, not one of the predefined ones. And if you have more parameters then the URL, you need to use the whole shebang. Also, it's probably better to use onbeforeunload than onunload.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 1 2012, 08:48 AM
Post #3


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



Some browsers ignore onunload events due to widespread abuse (such as sites opening popup windows when visitors try to leave)...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 1 2012, 09:16 AM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Yeah, I can't get it to work in Iron. But I never use that browser for personal use and there may be some popup blocker setting that I don't find.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
americast but from India
post Aug 1 2012, 10:23 AM
Post #5


Newbie
*

Group: Members
Posts: 12
Joined: 1-August 12
Member No.: 17,530



When the window is closed, nothing happens. I tried it with Chrome, Firefox and Opera. I used the full url. Do you have any other ideas of how to accomplish my target?

Thanx...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 1 2012, 10:42 AM
Post #6


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Works for me in FF at least. Sure you haven't disabled pop-ups?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
americast but from India
post Aug 1 2012, 11:22 AM
Post #7


Newbie
*

Group: Members
Posts: 12
Joined: 1-August 12
Member No.: 17,530



where have you put the script? Under the <body> tag or the <head> tag? I had used it in the <head> tag...

Thanx for any help...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 1 2012, 02:19 PM
Post #8


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



In HEAD.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
americast but from India
post Aug 2 2012, 03:03 AM
Post #9


Newbie
*

Group: Members
Posts: 12
Joined: 1-August 12
Member No.: 17,530



What did you write in place of "_blank"? Did you use single quotes in place of double? If possible please mention the exact lines you used.

Thanx again...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 2 2012, 07:46 AM
Post #10


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



I just removed it. Maybe I don't have the latest FF, but are you sure you haven't disabled popups?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
americast but from India
post Aug 3 2012, 11:13 AM
Post #11


Newbie
*

Group: Members
Posts: 12
Joined: 1-August 12
Member No.: 17,530



Great! On disabling popups, it works fine. But, my users will always have popups enable. How to bypass this popup?

Also, I have found that the new page (linked in the javascript) opens even if a I click a link in my website. But I do not want that. The reason is that I want to link my website to a 'Thank You' page, which the user should get only after he goes away from my site. The links given inside my site are the ones which are linked to different pages of my site. See if you can find a solution to this.

Thanx...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 3 2012, 11:53 AM
Post #12


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



So it works now?

That's a whole lot more complicated. I guess you would have to make JavaScript first check if the clicked link leads to a page on your domain and if so stop there.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
americast but from India
post Aug 3 2012, 12:11 PM
Post #13


Newbie
*

Group: Members
Posts: 12
Joined: 1-August 12
Member No.: 17,530



But how?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 3 2012, 12:31 PM
Post #14


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



I'm not sure. I think it would involve event listeners (google that) for checking the link clicks, but there also needs to be some logic to check if a link was clicked at all when the page unloads so the pop-after will fire if the window is simply closed.

BTW you realize no one will like this way of saying Thank you, don't you? wink.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
americast but from India
post Aug 4 2012, 12:09 PM
Post #15


Newbie
*

Group: Members
Posts: 12
Joined: 1-August 12
Member No.: 17,530



Might be they will, because over there I want to request them to write comments about my website smile.gif

Anyway, thanx for help...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
americast but from India
post Aug 5 2012, 03:39 AM
Post #16


Newbie
*

Group: Members
Posts: 12
Joined: 1-August 12
Member No.: 17,530



Have you heard of any command: onexit ?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
americast but from India
post Aug 5 2012, 03:40 AM
Post #17


Newbie
*

Group: Members
Posts: 12
Joined: 1-August 12
Member No.: 17,530



Have you heard of any command: onexit ?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 5 2012, 05:26 AM
Post #18


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



No. But googling javascript + exit or on exit might turn up some attempts to do what you want.

QUOTE
Might be they will, because over there I want to request them to write comments about my website smile.gif


Im sure that will make them thrilled...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Aug 5 2012, 05:12 PM
Post #19


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE
Have you heard of any command: onexit ?
Perhaps you're referring to the onclose event handler.

It's still a bad idea to use it to pester visitors to your site.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
americast but from India
post Aug 8 2012, 09:28 AM
Post #20


Newbie
*

Group: Members
Posts: 12
Joined: 1-August 12
Member No.: 17,530



Can you give a command similar to window.open or window.popup which will not be blocked by the popup blockers?

Thanx again...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

2 Pages V  1 2 >
Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 04:42 PM