Using JavaScript when page is opening in the new window that time how to hide the address bar

533 Views Asked by At

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>

1

There are 1 best solutions below

2
On

<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.