window.open javascript without the URL

Asked

Viewed 6,625 times

0

I’m trying to open a new javascript window, but without the URL... I’ve tried some ways and nothing... has anyone managed to remove it? Follow my initial test code below:

 <!DOCTYPE html>
<html>
<body>

<p>Click the button to open an about:blank page in a new browser window that is 200px wide and 100px tall.</p>

<button onclick="popupwindow()">Try it</button>

<script>
function popupwindow(url, title, w, h) {
 var w = 200;
        var h = 200;
        var left = Number((screen.width/2)-(w/2));
        var tops = Number((screen.height/2)-(h/2));

   return window.open('/', '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+tops+', left='+left);
   //return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 
</script>

</body>
</html>
  • 2

    this has worked: http://jsfiddle.net/8boju236/

  • 1

    Is your browser not blocking popup? This is your final code?

  • I tested in some browsers and nothing... the code just works does not hide or remove the URL...

2 answers

3


You cannot hide the address bar in modern browsers.

This is a modern browser security feature and there is no way around it with javascript or HTML.

Imagine that without this sites could mimic popups from other sites to try to steal passwords, for example pretending to allow you to log into the site using the facebook login, but instead of using the facebook API to show the popup it shows a fake popup that mimics the original.

If you don’t want to show the address bar I would say that the only alternative is to use some kind of modal inside the page and display the contents of the popup in a iframe.

1

Goodnight!

Your code is correct, I performed tests with the following browsers.

  • Mozilla Firefox Version 37.0.2
  • Google Chrome Version 44.0.2403.155 m
  • Microsoft Edge 20.10240.16384.0

I know I should not ask for clarification in the reply but at the moment I can not comment on your post, so I wonder if this is your final code, and which browser is using.

  • I upgraded to the latest version... the b.o that I need to remove the navigation bar...

  • I understand, now I understand the question, I never got to brush the address, you’re trying to make your html look more like a native app?

  • that’s right, but I saw that this would be a security feature... so I used the bootstrap dialog.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.