how to avoid about blank blocked while open a new tab

13,466

As stated by @Lain, just fill in the href attribute.

<a href="http://www.la.unm.edu" style="color:red;" onclick="window.open('http://www.la.unm.edu',null,'left=50,top=50,width=700,height=500,toolbar=1,location=0,resizable=1,scrollbars=1'); return false;">Limk</a>

Working Sandbox Demo (adding this to code snippet, because code snippet doesn't allow clicking links offsite)

If you want to completely control the context menu actions, so that "Open in a New Tab" behaves identically to window.open(), then you should probably look at this answer: How to add a custom right-click menu to a webpage?.

Why are you getting about:blank#blocked? Well, about:blank is just a blank page, and when you right click an element, and click something in the context menu, that does not fire the onClick event. So, it just shows a blank page.

Why does it say #blocked, then, too? Probably because href contains "javascript", and the browser is trying to stop malicious code from executing. There are few resources explaining this, but AskLeo.com says...

“about:blank#blocked” is sometimes displayed as the result of security software blocking access to something.

Share:
13,466

Related videos on Youtube

jcrshankar
Author by

jcrshankar

Updated on June 04, 2022

Comments

  • jcrshankar
    jcrshankar almost 2 years

    I am using the below code to open the page in a new window its working as expected but when I Right click "open in a new tab" its blocking with "about:blank#blocked", i am expecting the link to open in a new tab how to fix that?

    <a href="javascript:;" style="color:red;" onclick="window.open('http://www.la.unm.edu',null,'left=50,top=50,width=700,height=500,toolbar=1,location=0,resizable=1,scrollbars=1'); return false;">Limk</a>
    • Lain
      Lain over 3 years
      Put the link in the href instead of javascript:;.
    • jcrshankar
      jcrshankar over 3 years
      i tried by giving href="la.unm.edu" i have observed like, while closing the window its not going back to the main page from where the link got launched, rather its staying with the page(url) opened by open by window.open
    • Gitau Harrison
      Gitau Harrison over 2 years
      Had the same issue of about:blank#blocked. I had left out the closing </a> tag. Adding this fixed the problem.
  • jcrshankar
    jcrshankar over 3 years
    thanks for answering yes i understand that, before posting the question i tried by giving href="la.unm.edu" i have observed like, while closing the window its not going back to the main page from where the link got launched, rather its staying with the page(url) opened by open by window.open
  • HoldOffHunger
    HoldOffHunger over 3 years
    @jcrshankar: Okay, I think I understand now -- you want "open in new window" to behave exactly like window.open. In that case, you need to override the context menu, and make a custom one, so you can control the events of clicking on the context menu. Something like this: How to add a custom right-click menu to a webpage? Does that work? I can update my answer with mentioning that, if that's correct.
  • jcrshankar
    jcrshankar over 3 years
    hi, on PageA i have an Link. when i click on the link the new page(say PageB) should get load on new window using(window.open) when i am closing the window it should back to PageA again. similarly when i right click and selecting "open a new tab" on the link from PageA it should get load the PageB on a new tab.
  • HoldOffHunger
    HoldOffHunger over 3 years
    @jcrshankar: Hi, thanks for getting back to me. The code above seems to do exactly as you describe. I tested with a working demo. Click the link: Window pops up, close window, I'm back at the browser and the homepage. Right-click link, click open in new-tab, close new tab, I'm back at the browser and the homepage.