Why does the Google Chrome Popup Blocker reset the link when it contains an image or any other tag?

Currently, Google Chrome is a little strange that v25 no longer respects the 302 redirect header and happily rewrites the form data to refresh the page, while v24 and all other browsers play well. I'm not sure this is just a temporary browser error, so let me describe the secret I'm trying to solve.

As far as I know, you cannot open a tab using HTML or JavaScript, but a new window without explicitly defined dimensions will open as the default tab.

I tried this first:

<a href="URL" onclick="window.open(this.href);return false"> <img src="NICE IMAGE" alt="foo"> </a> 

This worked everywhere except Chrome, where it was hit as an unauthorized pop-up. Interestingly, sometimes, as I continued to click on it, Chrome changed my mind and let the connection open anyway (like a tab). This was not always the case, although sometimes the link remained dead.

After several hours of experimentation (and changing from onclick to simple target="_blank" ), I found that the reason the link was killed was because the click event started with the <img> in <a> . When I replaced <img> with <span> , which contained some text and clicked on <span> , the link could not open (Chrome defined it as an unwanted popup), but when I clicked on the <a> tag (with a fixed size or padding ), then it was accepted, and a new tab appeared.

Finally, I just included the images as the CSS background, and the <a> tags remained empty. Everything seems to work in every browser with this markup:

 <a href="URL" target="_blank" style="background:url('NICE_IMAGE'); height:XXX; width:XXX" title="Description"></a> 

What could be the reason for the logic of Google Chromes, when the link contains a tag, then it is forbidden to open as a new tab, but when it is empty, it can go forward?

+7
source share
1 answer

After some testing:

  • Chrome version - 25.0.1364.172 m: works great!
  • Chrome version - 26.0.1410.43 m: works great!

The "normal" way to open a tab works in both new versions. Tested!

my code is:

 <?php echo ' <a href="http://www.google.com" onclick="window.open(this.href); return false;"> <img src="http://static.adzerk.net/Advertisers/2565.png" alt="foo" /> </a> '; ?> 

the problem should be on your pages ...

EDIT: SEARCH SEARCH I searched for reported and corrected errors in this problem, but could not find anything.

+3
source

All Articles