How to hide URL in the popup window opened using window.open

If you are using below code to open a popup window in your web page, then address must be appearing in you pop up window and f you want to get rid of the address and do not want to show this to end user then you can follow the below example.

window.open("myPopupWindow.html", "_blank", "height=400, width=550, status=yes, toolbar=no, menubar=no, location=no, addressbar=no, top=200, left=300"); 

Solutions:

If you are just trying to mask the address, to make it look nicer or hide the fact that you’re linking to another website. Is it that you don’t want people to know they can access that page without using your popup?

If it’s the former, then what you could do is make the page you open in window.open an iframe, and point the iframe to your actual page. They user could still access the target page, but only via your nicer looking URL.

window.open('http://abc.com/message.html');

Your “message.html” page will contain the following content:

 <html>
       <body> 
          <iframe src="/realPage.html"></iframe>
       </body>

  </html>

If you want to open new tab then following code will work:

window.open('','_blank').location.href = "url"

Leave a Reply

Your email address will not be published. Required fields are marked *