{"id":14,"date":"2007-05-20T23:59:09","date_gmt":"2007-05-21T03:59:09","guid":{"rendered":"http:\/\/prglab.com\/blog\/?page_id=14"},"modified":"2009-02-25T10:11:38","modified_gmt":"2009-02-25T14:11:38","slug":"js-popupwindow","status":"publish","type":"page","link":"https:\/\/www.prglab.com\/blog\/js-tutorial\/js-popupwindow","title":{"rendered":"JavaScript\u5f39\u51fa\u7a97\u53e3"},"content":{"rendered":"<p>\u4f7f\u7528JavaScript\uff0c\u6211\u4eec\u53ef\u4ee5\u751f\u6210\u4e09\u79cd\u5f39\u51fa\u7a97\u53e3\uff1a\u63d0\u793a\u7a97\u53e3\uff0c\u786e\u8ba4\u7a97\u53e3\u548c\u63d0\u95ee\u7a97\u53e3\u3002<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n<strong>\u8b66\u793a\u7a97\u53e3 \uff08Alert Box\uff09<\/strong><br \/>\n\u8b66\u793a\u7a97\u53e3\u901a\u5e38\u7528\u6765\u786e\u4fdd\u7528\u6237\u6536\u5230\u67d0\u9879\u4fe1\u606f\uff0c\u56e0\u4e3a\u5f53\u4e00\u4e2a\u63d0\u793a\u7a97\u53e3\u5f39\u51fa\u540e\uff0c\u7528\u6237\u5fc5\u987b\u70b9\u51fb\u201c\u786e\u8ba4\u201d\uff08\u201cOK\u201d\uff09\u6309\u94ae\u624d\u80fd\u7ee7\u7eed\u3002<\/p>\n<p>\u8bed\u6cd5\uff1a<\/p>\n<table width=\"96%\" align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n<tr>\n<td class=\"quote\">alert(&#8220;\u6587\u672c\u5185\u5bb9&#8221;);<\/td>\n<\/tr>\n<\/table>\n<p>\u4f8b\u5b50\uff08\u5c06\u4f8b\u4e2d\u5185\u5bb9\u5b58\u4e3a\u4e00\u4e2ahtml\u6587\u4ef6\u4ee5\u6d4b\u8bd5\u6548\u679c\uff09\uff1a<\/p>\n<table width=\"96%\" align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n<tr>\n<td class=\"quote\">&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\nfunction disp_alert()<br \/>\n{<br \/>\n<span style=\"color: red\">alert(&#8220;\u4f60\u597d! &#8221; + &#8216;\\n&#8217; + &#8220;\u7b2c\u4e8c\u884c\u5185\u5bb9.&#8221;)<\/span><br \/>\n}<br \/>\n&lt;\/script&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;&lt;input type=&#8221;button&#8221; onclick=&#8221;<span style=\"color: red\">disp_alert()<\/span>&#8221; value=&#8221;\u663e\u793a\u63d0\u793a\u7a97\u53e3&#8221; \/&gt;&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/td>\n<\/tr>\n<\/table>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n<strong>\u786e\u8ba4\u7a97\u53e3\uff08Confirm Box\uff09<\/strong><br \/>\n\u786e\u8ba4\u7a97\u53e3\u901a\u5e38\u5728\u4f60\u9700\u8981\u7528\u6237\u9a8c\u8bc1\u6216\u63a5\u53d7\u67d0\u4e9b\u4fe1\u606f\u65f6\u4f7f\u7528\u3002<br \/>\n\u5f53\u4e00\u4e2a\u786e\u8ba4\u7a97\u53e3\u5f39\u51fa\u540e\uff0c\u7528\u6237\u5fc5\u987b\u9009\u62e9\u70b9\u51fb&#8221;\u786e\u8ba4&#8221;\uff08&#8221;OK&#8221;\uff09\u6216\u201c\u53d6\u6d88\u201d\uff08&#8221;Cancel&#8221;\uff09\u6309\u94ae\u624d\u80fd\u7ee7\u7eed\u3002<br \/>\n\u5982\u679c\u7528\u6237\u9009\u62e9&#8221;\u786e\u8ba4&#8221;\uff08&#8221;OK&#8221;\uff09\uff0c\u7a97\u53e3\u8fd4\u56de\u503c\u4e3a\u771f(true)\u3002\u5982\u679c\u7528\u6237\u9009\u62e9\u201c\u53d6\u6d88\u201d\uff08&#8221;Cancel&#8221;\uff09\uff0c\u7a97\u53e3\u8fd4\u56de\u503c\u4e3a\u5047(false)\u3002\u8bed\u6cd5\uff1a<\/p>\n<table width=\"96%\" align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n<tr>\n<td class=\"quote\">confirm(&#8220;\u6587\u672c\u5185\u5bb9&#8221;);<\/td>\n<\/tr>\n<\/table>\n<p>\u4f8b\u5b50\uff08\u5c06\u4f8b\u4e2d\u5185\u5bb9\u5b58\u4e3a\u4e00\u4e2ahtml\u6587\u4ef6\u4ee5\u6d4b\u8bd5\u6548\u679c\uff09\uff1a<\/p>\n<table width=\"96%\" align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n<tr>\n<td class=\"quote\">&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\nfunction disp_confirm()<br \/>\n{<br \/>\n<span style=\"color: red\">var r=confirm(&#8220;Press a button&#8221;)<\/span><br \/>\nif (r==true)<br \/>\n{<br \/>\ndocument.write(&#8220;You pressed OK!&#8221;)<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\ndocument.write(&#8220;You pressed Cancel!&#8221;)<br \/>\n}<br \/>\n}<br \/>\n&lt;\/script&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;&lt;input type=&#8221;button&#8221; onclick=&#8221;<span style=\"color: red\">disp_confirm()<\/span>&#8221; value=&#8221;\u663e\u793a\u786e\u8ba4\u7a97\u53e3&#8221; \/&gt;&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/td>\n<\/tr>\n<\/table>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n<strong>\u63d0\u95ee\u7a97\u53e3\uff08Prompt Box\uff09<\/strong><br \/>\n\u5982\u679c\u4f60\u9700\u8981\u7528\u6237\u5728\u8fdb\u5165\u9875\u9762\u524d\u5148\u8f93\u5165\u67d0\u4e9b\u4fe1\u606f\uff0c\u901a\u5e38\u4f7f\u7528\u63d0\u95ee\u7a97\u53e3\u3002<br \/>\n\u5f53\u4e00\u4e2a\u63d0\u95ee\u7a97\u53e3\u5f39\u51fa\u540e\uff0c\u7528\u6237\u9700\u8981\u8f93\u5165\u67d0\u4e9b\u4fe1\u606f\u5e76\u9009\u62e9&#8221;\u786e\u8ba4&#8221;\uff08&#8221;OK&#8221;\uff09\u6216\u201c\u53d6\u6d88\u201d\uff08&#8221;Cancel&#8221;\uff09\u65b9\u80fd\u7ee7\u7eed\u3002<br \/>\n\u5982\u679c\u7528\u6237\u9009\u62e9\u4e86&#8221;\u786e\u8ba4&#8221;\uff08&#8221;OK&#8221;\uff09\uff0c\u7a97\u53e3\u8fd4\u56de\u503c\u4e3a\u7528\u6237\u8f93\u5165\u7684\u4fe1\u606f\uff0c\u5426\u5219\uff0c\u8fd4\u56de\u7a7a\u503c(null)\u3002<\/p>\n<p>\u8bed\u6cd5\uff1a<\/p>\n<table width=\"96%\" align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n<tr>\n<td class=\"quote\">prompt(&#8220;\u6587\u672c\u5185\u5bb9&#8221;,&#8221;\u9ed8\u8ba4\u503c&#8221;)<\/td>\n<\/tr>\n<\/table>\n<p>\u4f8b\u5b50\uff08\u5c06\u4f8b\u4e2d\u5185\u5bb9\u5b58\u4e3a\u4e00\u4e2ahtml\u6587\u4ef6\u4ee5\u6d4b\u8bd5\u6548\u679c\uff09\uff1a<\/p>\n<table width=\"96%\" align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n<tr>\n<td class=\"quote\">&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\nfunction disp_prompt()<br \/>\n{<br \/>\n<span style=\"color: red\">var name=prompt(&#8220;Please enter your name&#8221;,&#8221;Aqua&#8221;)<\/span><br \/>\nif (name!=null &amp;&amp; name!=&#8221;&#8221;)<br \/>\n{<br \/>\ndocument.write(&#8220;Hello &#8221; + name + &#8220;! How are you today?&#8221;)<br \/>\n}<br \/>\n}<br \/>\n&lt;\/script&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;&lt;input type=&#8221;button&#8221; onclick=&#8221;<span style=\"color: red\">disp_prompt()<\/span>&#8221; value=&#8221;\u663e\u793a\u63d0\u95ee\u7a97\u53e3&#8221; \/&gt;&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528JavaScript\uff0c\u6211\u4eec\u53ef\u4ee5\u751f\u6210\u4e09\u79cd\u5f39\u51fa\u7a97\u53e3\uff1a\u63d0\u793a\u7a97\u53e3\uff0c\u786e\u8ba4\u7a97\u53e3\u548c\u63d0\u95ee\u7a97\u53e3\u3002 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- \u8b66\u793a\u7a97\u53e3 \uff08Alert Box\uff09 \u8b66\u793a\u7a97\u53e3\u901a\u5e38\u7528\u6765\u786e\u4fdd\u7528\u6237\u6536\u5230\u67d0\u9879\u4fe1\u606f\uff0c\u56e0\u4e3a\u5f53\u4e00\u4e2a\u63d0\u793a\u7a97\u53e3\u5f39\u51fa\u540e\uff0c\u7528\u6237\u5fc5\u987b\u70b9\u51fb\u201c\u786e\u8ba4\u201d\uff08\u201cOK\u201d\uff09\u6309\u94ae\u624d\u80fd\u7ee7\u7eed\u3002 \u8bed\u6cd5\uff1a alert(&#8220;\u6587\u672c\u5185\u5bb9&#8221;); \u4f8b\u5b50\uff08\u5c06\u4f8b\u4e2d\u5185\u5bb9\u5b58\u4e3a\u4e00\u4e2ahtml\u6587\u4ef6\u4ee5\u6d4b\u8bd5\u6548\u679c\uff09\uff1a &lt;html&gt; &lt;head&gt; &lt;script type=&#8221;text\/javascript&#8221;&gt; function disp_alert() { alert(&#8220;\u4f60\u597d! &#8221; + &#8216;\\n&#8217; + &#8220;\u7b2c\u4e8c\u884c\u5185\u5bb9.&#8221;) } &lt;\/script&gt; &lt;\/head&gt; &lt;body&gt;&lt;input type=&#8221;button&#8221; onclick=&#8221;disp_alert()&#8221; value=&#8221;\u663e\u793a\u63d0\u793a\u7a97\u53e3&#8221; \/&gt;&lt;\/body&gt; &lt;\/html&gt; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; \u786e\u8ba4\u7a97\u53e3\uff08Confirm Box\uff09 \u786e\u8ba4\u7a97\u53e3\u901a\u5e38\u5728\u4f60\u9700\u8981\u7528\u6237\u9a8c\u8bc1\u6216\u63a5\u53d7\u67d0\u4e9b\u4fe1\u606f\u65f6\u4f7f\u7528\u3002 \u5f53\u4e00\u4e2a\u786e\u8ba4\u7a97\u53e3\u5f39\u51fa\u540e\uff0c\u7528\u6237\u5fc5\u987b\u9009\u62e9\u70b9\u51fb&#8221;\u786e\u8ba4&#8221;\uff08&#8221;OK&#8221;\uff09\u6216\u201c\u53d6\u6d88\u201d\uff08&#8221;Cancel&#8221;\uff09\u6309\u94ae\u624d\u80fd\u7ee7\u7eed\u3002 \u5982\u679c\u7528\u6237\u9009\u62e9&#8221;\u786e\u8ba4&#8221;\uff08&#8221;OK&#8221;\uff09\uff0c\u7a97\u53e3\u8fd4\u56de\u503c\u4e3a\u771f(true)\u3002\u5982\u679c\u7528\u6237\u9009\u62e9\u201c\u53d6\u6d88\u201d\uff08&#8221;Cancel&#8221;\uff09\uff0c\u7a97\u53e3\u8fd4\u56de\u503c\u4e3a\u5047(false)\u3002\u8bed\u6cd5\uff1a confirm(&#8220;\u6587\u672c\u5185\u5bb9&#8221;); \u4f8b\u5b50\uff08\u5c06\u4f8b\u4e2d\u5185\u5bb9\u5b58\u4e3a\u4e00\u4e2ahtml\u6587\u4ef6\u4ee5\u6d4b\u8bd5\u6548\u679c\uff09\uff1a &lt;html&gt; &lt;head&gt; &lt;script type=&#8221;text\/javascript&#8221;&gt; function disp_confirm() { var r=confirm(&#8220;Press a button&#8221;) if (r==true) { document.write(&#8220;You pressed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3,"menu_order":7,"comment_status":"open","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/14"}],"collection":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/comments?post=14"}],"version-history":[{"count":0,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/14\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/3"}],"wp:attachment":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/media?parent=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}