0

I need some help. I want to hide the address bar when opening the webpage in a new window. I tried all possible ways but I could make it possible. If anyone has an idea to do that please help on this.

Below I mentioned the sample pages. I am opening the second page from the first page in the new window. When opening that time I need to hide the second HTML page address bar or instead of that page I need to keep some black or any text.

firstPage.html

<html>
    <script>
    </script>
    <body>
        <h1>The a element</h1>
        <a href="target.htm" onclick="window.open('file:/Documents/docView.html', 'myWin', 'toolbar=0, directories=no,location=no, status=yes, menubar=0,resize=no, scrollbars=yes'); return false">Print</a>
    </body>
</html>

SecondPage.html

<html oncontextmenu="return false;">
   <head>
   <meta name="viewport" content="width=device-width, initial-scale=1">
      <style>
      </style>
      <script >
         
         function myFunction() {
                  window.resizeTo(1024,750);
         }
         
         document.onkeypress = function (event) {
                  event = (event || window.event);
                  return keyFunction(event);
         }
         document.onmousedown = function (event) {
                  event = (event || window.event);
                  return keyFunction(event);
         }
         document.onkeydown = function (event) {
                  event = (event || window.event);
                  return keyFunction(event);
         }
         
         //Disable right click script 
         function clickIE() {
             if (document.all) {
                 alert("Sorry, right-click has been disabled");
                 return false;
              }
         } 
         function clickNS(e) {
                  if (document.layers||(document.getElementById&&!document.all)) {
                           if (e.which==2||e.which==3) {
                                    alert("Sorry, right-click has been disabled");
                                    return false;
                           }
                  }
         } 
         if (document.layers){
             document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
         }else{
                  document.onmouseup=clickNS;
                  document.oncontextmenu=clickIE;
         } 
         
         document.oncontextmenu=new Function("return false")
         
         function keyFunction(event){
                  //Ctrl+Shift+I
                  if (event.ctrlKey && event.shiftKey && event.keyCode == 73) {
                           alert('The action you performed is unauthorized. Copying any content from this website is restricted');
                  return false;
                  }
                  //Ctrl+Shift+J
                  if (event.ctrlKey && event.shiftKey && event.keyCode == 74) {
                           alert('The action you performed is unauthorized. Copying any content from this website is restricted');
                  return false;
                  }
                  //Ctrl+Shift+U
                  if (event.ctrlKey && event.keyCode == 85) {
                           alert('The action you performed is unauthorized. Copying any content from this website is restricted');
                  return false;
                  }
                  //F12 || S || F5 || C || V || Insert || P || Z || right window key || Windows Menu / Right || Delete || Print Screen || Shift || Ctrl || Alt ||  Print || Refresh
                  if (event.keyCode == 123 || event.keyCode == 83 || event.keyCode == 116 || event.keyCode == 67 || event.keyCode == 86 || event.keyCode == 45 || event.keyCode == 80 || event.keyCode == 91 || event.keyCode == 92 || event.keyCode == 93 || event.keyCode == 46 || event.keyCode == 44 || event.keyCode == 16 || event.keyCode == 17 || event.keyCode == 18 || event.keyCode == 42 || event.keyCode == 168) {
                      alert('The action you performed is unauthorized. Copying any content from this website is restricted');
                  return false;
                  }
         }
         
         function closeWindow(){
                 setTimeout('window.close()', 30000);
         }
      </script>
   </head>
   <body onload="closeWindow()" onresize="myFunction()">
      <iframe style="width:1024px" height="750" src="file://BPM%20Project/BAW_Exercises.pdf#toolbar=0"></iframe>
      <div style="width:1020px;height:750px;background-color:transparent;position:absolute;top:0px;max-width: 100%;">
   </body>
</html>
  • Why do you think this is possible? Shouldn't this be handled by the browser itself to not confuse the user? – cloned Jun 28 '21 at 10:57
  • 3
    Does this answer your question? [Hiding the address bar of a browser (popup)](https://stackoverflow.com/questions/15926105/hiding-the-address-bar-of-a-browser-popup) – Ms.Tamil Jun 28 '21 at 10:58
  • And setting your own window sizes will not work everywhere either. (My browser is configured to _always_ open full-sized new tabs instead of any free-floating “popups”.) – CBroe Jun 28 '21 at 11:03
  • I don't want to show my web address URL in the browser. If I show the browser URL in the new window then the customer can easily be copied and open it into another browser and get the things from developer tools. For this process, I am trying to hide the address bar in the new window. – Bala Bhavani Illa Jun 28 '21 at 18:00
  • "location=no" is not working – Bala Bhavani Illa Jul 01 '21 at 02:51

1 Answers1

0

<html>
    <script>
    </script>
    <body>
        <h1>The a element</h1>
        <button onclick="window.open('http://www.google.com/target.html','','postwindow');">Print</button>
    </body>
</html>

You can find detailed information at https://developer.mozilla.org/en-US/docs/Web/API/Window/open.