Here's an example of how to open a new window with dynamic content using Javascript.
<SCRIPT LANGUAGE="JavaScript"> function openindex() { OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no"); OpenWindow.document.write("<TITLE>Title Goes Here</TITLE>") OpenWindow.document.write("<SCRIPT TYPE='Text/Javascript'>function Hello() { alert('Hello World!'); }</SCR" + "IPT>") OpenWindow.document.write("<BODY BGCOLOR=pink>") OpenWindow.document.write("<h1>Hello!</h1>") OpenWindow.document.write("This text will appear in the window!") OpenWindow.document.write("</BODY>") OpenWindow.document.write("</HTML>")
OpenWindow.document.close() self.name="main" } </SCRIPT> |
There is a need to split up the Javascript tag inside the document.write(…) to prevent the main tag outside from closing unexpectedly.
(Reference: http://www.htmlgoodies.com/beyond/javascript/article.php/3471221/So-You-Want-To-Open-A-Window-Huh.htm)
No comments:
Post a Comment