0

我需要一些帮助。我想在新窗口中打开网页时隐藏地址栏。我尝试了所有可能的方法,但我可以做到。如果有人有这样做的想法,请对此提供帮助。

下面我提到了示例页面。我正在新窗口中从第一页打开第二页。打开那个时候,我需要隐藏第二个 HTML 页面地址栏,或者我需要保留一些黑色或任何文本来代替该页面。

第一页.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>

第二页.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>

4

1 回答 1

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>

您可以在https://developer.mozilla.org/en-US/docs/Web/API/Window/open找到详细信息。

于 2021-06-28T14:55:53.290 回答