通过单击按钮打开弹出窗口

Open a popup by clicking on a button

我有一个 link 打开页面的小弹出窗口(不是新选项卡)。 我想将此功能集成到一个按钮中。不幸的是,这并没有像希望的那样工作。

好例子link:

<a href='#' onclick='window.open **
("https://google.com","mywindow", 
"menubar=1,resizable=1,width=500,height=500")'>
Link</a>

应该执行相同操作的当前按钮:

<form>
  <input class="btnstylega" onclick="window.location.href='https://google.com'" type="button" value="Link" />
</form>

你为什么不试试:

  <form><input class="btnstylega" onclick="window.open('https://google.com','mywindow', 
  'menubar=1,resizable=1,width=500,height=500')" 
  type="button" value="Neue Versicherung hinzufügen" /></form>

使用 _blanktarget 属性;这将打开一个新标签:

<form>
  <input class="btnstylega" type="button" value="Neue Versicherung hinzufügen" target="_blank" />
</form>

或者如果您想打开一个新的 window,请使用 onClick 属性:

<button class="button" onClick="window.open('http://www.example.com');">
     <span class="icon">Open</span>
</button>

这里,不要忘记 "window.open('http://www.example.com');" 两边的引号。

发生这种情况是因为您将 window 位置设置为一个,而不是创建新的 window。

此修改后的代码应按预期工作:

<form><input class="btnstylega" 
onclick="window.open('https://google.com','mywindow', 
'menubar=1,resizable=1,width=500,height=500')" 
type="button" value="Link" /></form>