Redirect into new tab, Redirection |
Redirect into new tab, Redirection |
americast but from India |
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> |
pandy |
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. |
Christian J |
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)...
|
pandy |
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.
|
americast but from India |
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... |
pandy |
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?
|
americast but from India |
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... |
pandy |
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.
|
americast but from India |
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... |
pandy |
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?
|
americast but from India |
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... |
pandy |
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. |
americast but from India |
Aug 3 2012, 12:11 PM
Post
#13
|
Newbie Group: Members Posts: 12 Joined: 1-August 12 Member No.: 17,530 |
But how?
|
pandy |
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? |
americast but from India |
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
Anyway, thanx for help... |
americast but from India |
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 ?
|
americast but from India |
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 ?
|
pandy |
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 Im sure that will make them thrilled... |
Darin McGrew |
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. |
americast but from India |
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... |
Lo-Fi Version | Time is now: 19th April 2024 - 01:02 AM |