如何打开多个弹出窗口?

Gra*_*y M 4 javascript popup popupwindow

我有五个链接,每个链接都指向一个页面。

function TohokuImgPopup(url) { 
popupWindow = window.open(
                    url, 'popUpWindow'+randomno, 'height=246,width=228,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no')
            }
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的功能。我对5个链接有不同的功能,每个链接都会打开一个新窗口。但是我一次只能打开一个弹出窗口。如何打开多个弹出窗口?

Gra*_*y M 5

我找到了答案。

<script type="text/javascript">

$(document).ready(


function a1(url) { 
popupWindow1 = window.open(
                    url, 'popUpWindow1', 'height=250,width=234,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no')
            }

            function a2(url) { 
popupWindow2 = window.open(
                    url, 'popUpWindow2', 'height=250,width=234,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no')
            }

            function a3(url) { 
popupWindow3 = window.open(
                    url, 'popUpWindow3', 'height=308,width=299,left=0,top=0,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no')
            }
            }
</script>

<a href="JavaScript:a1('images/focus_img1.html');">focus 1</a>
<a href="JavaScript:a2('images/focus_img2.html');">focus 2</a>
<a href="JavaScript:a3('images/focus_img3.html');">focus 3</a>
Run Code Online (Sandbox Code Playgroud)

这些链接将在单独的窗口中打开

  • 没有可扩展的解决方案。为每个链接硬编码一个函数不利于长期运行 (2认同)