SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Open new window with content

    Is it possible to open an exsisting window using window.open and then add a button and a text box to that window using javascript, and if so how?

    Thanks

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function newwin() {
    	var w = window.open("about:blank");
    	var btn = w.document.body.appendChild(w.document.createElement("button"));
    	btn.innerHTML = "click me";
    	btn.onclick = function () {
    		alert("you clicked me");
    	}
    }
    </script>
    </head>
    <body>
    <button onclick="newwin();">open window</button>
    </body>
    </html>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •