简体   繁体   中英

how can i create a new close button in my popup window in JS?

<!DOCTYPE html>
<html>
<body>

<p>Click the button to open an about:blank page in a new browser window  </p>
   <p id="demo"></p>

<button onclick="javascript: myFunction()">Try it</button>


<script  type="text/javascript">
                function myFunction() 
                {
                                var myWindow = window.open("http://192.168.1.101/sarika/Popups/tryit.html#part1", "","toolbar=yes, scrollbars=yes, resizable=yes, top=200, left=500, width=400, height=200,location=yes,fullscreen=no");
                                myWindow.document.write(location.host);
                                myWindow.document.write(navigator.taintEnabled());
                                //myWindow.document.write(history.length);
                                myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px tall!</p>");
                                myWindow.document.write("<button name='close' onclick='window.close()'  >Close</button>");   
                }


                 function redirect()
                 {
                    window.location.href = "page2.php";
                 }

</script>
 <body>
<A HREF="page2.php"> Page 2</A><br>
<INPUT TYPE="button" VALUE="New page" ONCLICK="redirect();">

</body>
</html>

How can i create a new button on my popup to close that popup on click of close button please help me. am not getting how to create a new button in popup.

The problem is with navigator.tainEnabled() . It is no longer supported in javaScript.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM