Home >
Technical & Creative Skills >
Programming, Servers & Scripts
How To Open In New Window without Pop Up Getting Blocked In Browser (8)
09-02-2017 08:38 PM
#1
stayhumble (Member)
How To Open In New Window without Pop Up Getting Blocked In Browser
So im trying to open my links in a new window from my landing page.
Its a quiz type landing page and I want the results to open in a new window.
when I use the open in new window, it gets blocked in my chrome & mozzila as a "pop Up"
and the user has to accepet pop ups from this domain
am i coding something wrong? is it my server?
thanks!
09-03-2017 12:42 AM
#2
manu_adefy (Veteran Member)
Nope, that's pretty standard to get blocked for a few years now. Tried doing it in several ways, none work.
09-04-2017 02:55 AM
#3
erikgyepes (Moderator)
Did you try?
HTML Code:
<a href="http://google.com" target="_blank">new tab</a>
Opening new tabs (on phone it's a new window) should still work fine.
09-04-2017 04:58 AM
#4
manu_adefy (Veteran Member)

Originally Posted by
erikgyepes
Did you try?
HTML Code:
<a href="http://google.com" target="_blank">new tab</a>
Opening new tabs (on phone it's a new window) should still work fine.
Never tried it by itself, I assumed the context is that you also do some changes in the parent tab.
If you just open in a new tab, higher chances it works but not guaranteed. Chrome is blocking a lot of those things nowadays. I remember trying that a lot when looking for ways to throw in 2 offers for each click.
09-04-2017 02:31 PM
#5
danielt (Member)
Put this attribute dynamically on your links and you can open 1 popup without being blocked
Code:
<script>
// here we define the click function
window.popclick = function(el, e){
var clickUrl = el.getAttribute('data-pop'); // we get the pop URL from the 'data-pop' attribute
var pop = window.open(clickUrl, '_blank', 'top=0,left=0,width='+screen.width+',height='+screen.height);
pop && pop.focus();
};
// here we put the attribute on all links on the page
var links = document.querySelectorAll('a');
for(var i in links){
links[i].setAttribute('onclick', 'popclick(this,event);');
}
</script>
// this is the result
<a href="http://url.com" onclick="popclick(this,event);" data-pop="http://popurl.com">Click me</a>
Have fun with it.
PS. What Erik said is also valid, you can use the above method to do a click _blank and then refresh the
origin page to something else
09-04-2017 02:52 PM
#6
manu_adefy (Veteran Member)

Originally Posted by
danielt
PS. What Erik said is also valid, you can use the above method to do a click _blank and then refresh the
origin page to something else
Unless Chrome became much more permissive all of a sudden, that method didn't work 1 year ago.
Would be epic if it did, are you actively using it?
09-04-2017 02:53 PM
#7
danielt (Member)
Yup
I can confirms it
09-04-2017 02:57 PM
#8
manu_adefy (Veteran Member)

Originally Posted by
danielt
Yup

I can confirms it
That means $$$
Home >
Technical & Creative Skills >
Programming, Servers & Scripts