Jump to content


Photo

On close browser.

jquery browser

  • Please log in to reply
8 replies to this topic

#1 lilmer

lilmer
  • Members
  • PipPipPip
  • Advanced Member
  • 132 posts
  • LocationSomewhere here in the universe.

Posted 01 December 2016 - 08:51 AM

Hello, I want to add a process that will trigger a show of advertisement or opening a new tab when the user close a the tab or browser. 

$(window).bind("beforeunload", function(e) {

    window.open(URL+'ads', '_blank');

    return 'You are closing the browser';

});

The window.open and the return message is both not working. I tried also other possibilities but window.open is not working. Anyone knows about this?



#2 requinix

requinix
  • Administrators
  • Lazy Administrator
  • 9,380 posts
  • LocationWA

Posted 01 December 2016 - 12:33 PM

What you want to do is despicable.

Are you saying the onbeforeunload works but the window.open does not? If it's not a problem with the code itself (eg, "URL" undefined or invalid) then it's likely that the browser is deliberately preventing that from happening.
The Reimann Zeta Function Trolley Problem | "Summer is when I, the great ice fairy, can show my true power!"

#3 Jacques1

Jacques1
  • Members
  • PipPipPip
  • Turtles all the way down
  • 4,224 posts

Posted 01 December 2016 - 03:44 PM

What you want to do is despicable.

 

I couldn't agree more.

 

Aggressive ads are already the cancer of the Internet, but popping up a new window when I want to close the current one makes me want to punch the developer in the face.

 

Seriously, stop it. Even if you manage to get your code past the browser's malware filter, your users will be truly annoyed and either turn their ad blocker all the way up or leave your site forever. It's just counter-productive.



#4 Psycho

Psycho
  • Moderators
  • Move along, nothing to see here
  • 11,848 posts
  • LocationCanada

Posted 01 December 2016 - 03:51 PM

I would comment on what the OP is wanting to implement. But, then I would have to ban myself for language.


The quality of the responses received is directly proportional to the quality of the question asked.

I do not always test the code I provide, so there may be some syntax errors. In 99% of all cases I found the solution to your problem here: http://www.php.net

#5 lilmer

lilmer
  • Members
  • PipPipPip
  • Advanced Member
  • 132 posts
  • LocationSomewhere here in the universe.

Posted 15 December 2016 - 07:45 AM

Nope, its not a usual page ads thats keeps on triggering every time you exit a site. This is for specific user and by user level, and once you agree to terms it will not pop again.



#6 Jacques1

Jacques1
  • Members
  • PipPipPip
  • Turtles all the way down
  • 4,224 posts

Posted 15 December 2016 - 12:08 PM

It doesn't matter what kind of ad this is. It's garbage.



#7 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,870 posts

Posted 15 December 2016 - 08:58 PM

Literally the only thing I have ever seen popup when I try to close my tab/browser or otherwise navigate from the page that I only _marginally_ consider "okay" (read: barely tolerable) is a warning about losing unsaved changes to something.  


Edited by .josh, 15 December 2016 - 08:59 PM.

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#8 Stefany93

Stefany93
  • Members
  • PipPipPip
  • Advanced Member
  • 263 posts
  • LocationThe motherland of Perl
  • Age:23

Posted 31 December 2016 - 07:16 PM

^^ Actually I find the pop-up quite useful if I am writing something and accidentally click the close button on a tab or browser (pls don't hate me, lol) especially if there is no auto safe.

As for the op, it is not possible to write to add a custom message onbeforeunload or any event that is triggered when the user wants to leave. You can add some text (on few browsers) additionally to the default message and that's it. Browsers do that for defense.

Edited by Stefany93, 31 December 2016 - 07:17 PM.

"Put your faith in God and keep your powder dry" - Oliver Cromwell
My site - http://stefanynewman.info
 


#9 Stielle

Stielle
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 06 January 2017 - 01:27 PM

^^ Actually I find the pop-up quite useful if I am writing something and accidentally click the close button on a tab or browser (pls don't hate me, lol) especially if there is no auto safe.
 

This is acceptable if I have coded an application that a user is working in and wants to leave an area without saving.

But as a 'WAIT DON'T LEAVE!' for a webpage, I make a point to not go back to that site again, report it, etc.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users