How Do I Open a Pop Up Window over Destination URL?

只愿长相守 提交于 2020-01-26 04:06:10

问题


I want to link to a url and after the destination page opens, pop up a window over it. I've seen some examples of this but don't know how to code it. I'm a .NET developer but perhaps this needs javascript? Anyone know how to do it?

Page 1

Link 2 Page 2 ---> Page 2 opens... Popup opens over Page 2.

Thanks.


回答1:


Approach #1:

In Page 2:

<script>
if (document.referrer === "URL of Page 1 goes here")
{
    window.open("URL of popup goes here", "_blank");
}
</script>

Thus the popup will only appear if you arrived at Page 2 via a link from Page 1.

Approach #2 (if you cannot modify Page 2):

In Page 1:

<script>
    function page2popup()
    {
        window.open("URL of popup goes here", "_blank");
    }
</script>
<a href="URL of Page 2 goes here" onclick="page2popup();">Page 2</a>



回答2:


if you are doing this in html, then

page1.html

<html>
<head>

</head>
<body>
    <a href="page2.html">click to go to page to page2</a>
</body>
</html>

page2.html

<html>
<head>
    <script type="text/javascript">
    function popup(){
        //alert("this is page 2");
        window.open("http://www.geekzgarage.com"); 
    }
    </script>
</head>
<body onload="popup()">
    this is page 2 and popup window is opened as provided in the link given..
</body>
</html>


来源:https://stackoverflow.com/questions/29169827/how-do-i-open-a-pop-up-window-over-destination-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!