单击打开新窗口 javascript



我正在尝试使用Javascript打开新窗口。我的代码如下。

function openMeeting()
{
  var popup = window.open("myurl", "_blank", "menubar= yes,scrollbars=yes,resizable=yes,top=500,left=500,width="+screen.availWidth+",height="+screen.availHeight);
  if (popup == null)
     alert('Please change your popup settings', popup);
}
    <li class="nav-item"> <a href="#" class="nav-link" onclick="openMeeting();"> Join meeting </a> </li>
    

使用此代码打开新窗口,但它与新选项卡不同,菜单丢失。我还需要显示书签。

复制此代码,在代码片段/堆栈溢出中不允许打开弹出窗口。

function openMeeting()
{
   var popup = window.open("https://stackoverflow.com", "popUpWindow", "height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes");
    
   if (popup == null) alert('Please change your popup settings');
   
}
/*
menubar= yes,scrollbars=yes,resizable=yes,top=500,left=500,width="+screen.availWidth+",height="+screen.availHeight
window.open('https://www.quackit.com/javascript/examples/sample_popup.cfm','popUpWindow','height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes')
*/
<li class="nav-item"> <a href="#" class="nav-link" onclick="openMeeting();"> Join meeting </a> </li>

这可能是不可能的阅读此内容 : https://bugs.chromium.org/p/chromium/issues/detail?id=82522

试试这个:

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<a class="link">Link</a>
<script  type="text/javascript">
     $("a.link").on("click",function(){
         window.open('http://google.com','_blank');
     });
</script>
</body>
</html>

最新更新