{"id":334,"date":"2010-04-14T11:30:40","date_gmt":"2010-04-14T11:30:40","guid":{"rendered":""},"modified":"2010-04-14T11:30:40","modified_gmt":"2010-04-14T11:30:40","slug":"334","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=334","title":{"rendered":"\u65b0\u6539\u8fdb\u7248\u767e\u5ea6Popup.js\u5f39\u51fa\u6846_\u62d6\u62fd\u5c0f\u6846\u67b6_\u517c\u5bb9IE6\/7\/8,Firefox,Chrome"},"content":{"rendered":"<p>\u3000\u3000\u767e\u5ea6\u7a7a\u95f4\u7684\u5f39\u51fa\u7a97\u53e3\u548c\u62d6\u62fd\u6548\u679c(\u4e5f\u5c31\u662fpopup.js),\u4ee3\u7801\u7cbe\u7b80\uff0c\u6548\u679c\u4e5f\u5f88\u597d\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u5f88\u591a\u5927\u578b\u7f51\u7ad9\u4e0a\u89c1\u5230\u8fd9\u79cd\u6548\u679c\uff0c\u4eca\u5929\u5076\u7136\u9047\u5230\u8fd9\u6b3e\u6539\u8fdb\u7248\uff0c\u6211\u4eec\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u3002<br \/><img decoding=\"async\" src=\"http:\/\/www.poloo.org\/wp-content\/attachments\/month_1004\/l201041411294.jpg\" \/><br \/>\u3000\u3000\u539f\u6709\u767e\u5ea6\u7684Popup.js\u5728\u6709<br \/><code>&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"<a href=\"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\" target=\"_blank\" rel=\"external\">http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd<\/a>\"&gt;<\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u58f0\u660e\u7684\u7f51\u9875\u4e0b\u5b58\u5728\u517c\u5bb9\u6027\u95ee\u9898\uff0c\u5373\u5728IE6,7,8\u4e0b\uff0c\u906e\u7f69\u5c42\u662f\u53ef\u4ee5\u5168\u5c4f\uff0c\u4f46\u5728Firefox\u548cChrome\u4e0b\u65e0\u6cd5\u5168\u5c4f\u906e\u7f69\u3002<br \/>\u3000\u3000\u9020\u6210\u906e\u7f69\u5c42\u5728FF\u548cChrome\u4e0b\u65e0\u6cd5\u5168\u5c4f\u7684\u95ee\u9898\u5728267\u884c\uff1a<br \/><code>var C = '&lt;div id=\"dialogBoxBG\" style=\"position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:' + A + \";\" + H + \"background-color:\" + this.color.cColor + ';display:none;\"&gt;&lt;\/div&gt;';<\/code><\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u906e\u7f69\u5c42dialogBoxBG \u7684style\u53ea\u662f\u5355\u7eaf\u7684\u8bbe\u7f6e\u4e3aheight:100%\uff0c\u6240\u4ee5\u5728\u6709&lt;!DOCTYPE&#8230;&gt;\u58f0\u660e\u4e0b\u7684\u9875\u9762\u65e0\u6cd5\u517c\u5bb9FF\u548cChrome\u3002<br \/>\u3000\u3000\u7136\u800c\u76ee\u524d\u7f51\u4e0a\u6709\u4e00\u4e2a\u201cluocheng\u201d\u7684\u201c\u5b8c\u7f8e\u7248\u201dpopup.js\uff0c\u4e0b\u8f7d\u4e0b\u6765\u8bd5\u7528\u4e86\u4e0b\uff0c\u7ed3\u679c\u5e76\u6ca1\u6709\u5b8c\u5168\u517c\u5bb9FF\u548cChrome\uff0c\u8fd8\u662f\u5b58\u5728\u906e\u7f69\u5c42\u65e0\u6cd5\u5168\u5c4f\u7684bug\uff0c\u8bfb\u4e86\u4e00\u4e0b\u6e90\u4ee3\u7801\uff0c\u627e\u5230\u4e86\u9519\u8bef\u6240\u5728\uff1aluocheng\u7684\u7248\u672c\u4e2d\u589e\u52a0\u4e86\u4e00\u4e2agetValue\u65b9\u6cd5\uff0cswitch\u8bed\u53e5\u4e2d\u7684case &#8220;clientHeight&#8221;:\u7adf\u7136\u6709\u4e24\u4e2a\uff01\u5220\u6389\u4e00\u4e2a\u4ee5\u540e\u7ee7\u7eed\u6d4b\u8bd5\uff0c\u8fd8\u662f\u65e0\u6cd5\u517c\u5bb9FF\u548cChrome\uff0c\u7ee7\u7eed\u8bfb\u4ee3\u7801\u6392\u9519\uff0c\u589e\u52a0\u7684setBackgroundSize\u65b9\u6cd5\u4e2dG(&#8216;dialogBoxBG&#8217;).style.height = getValueHeight;\u53ea\u662f\u590d\u5236\u7ed9\u906e\u7f69\u5c42dialogBoxBG\u7684height=\u6574\u6570\u503c\uff0c\u8fd9\u4e2a\u662f\u4e0d\u9075\u5faaweb\u6807\u51c6\u7684\uff0c\u6240\u4ee5\u5728FF\u548cChrome\u4e0b\u5b58\u5728bug\u3002<br \/><code>setBackgroundSize: function() {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var getValueWidth;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var getMaxValueWidth = [getValue(\"clientWidth\"), getValue(\"scrollWidth\")];<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getValueWidth = eval(\"Math.max(\" + getMaxValueWidth.toString() + \")\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;G('dialogBoxBG').style.width = getValueWidth;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var getValueHeight;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var getMaxValueHeight = [getValue(\"clientHeight\"), getValue(\"scrollHeight\")];<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getValueHeight = eval(\"Math.max(\" + getMaxValueHeight.toString() + \")\");<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;G('dialogBoxBG').style.height = getValueHeight;&nbsp;&nbsp;&nbsp;&nbsp;},<\/code><br \/><strong>\u89e3\u51b3\u65b9\u6cd5\u5f88\u7b80\u5355\uff1aG(&#8216;dialogBoxBG&#8217;).style.height = getValueHeight;\u4fee\u6539\u6210G(&#8216;dialogBoxBG&#8217;).style.height = getValueHeight + &#8220;px&#8221;;\u5373\u53ef\u3002<\/strong><\/p>\n<p>\u3000\u3000\u4ee4\u9644\u4e0a\u83b7\u53d6\u9875\u9762\u9ad8\u5ea6\u5728\u4e0d\u540c\u6d4f\u89c8\u5668\u4e4b\u95f4\u7684\u5dee\u5f02\u53c2\u8003\u8d44\u6599\uff1a<br \/>\u3000\u3000clientHeight\uff1a\u5728IE\u548cFF\u4e0b\uff0c\u8be5\u5c5e\u6027\u6ca1\u4ec0\u4e48\u5dee\u522b\uff0c\u90fd\u662f\u6307\u6d4f\u89c8\u5668\u7684\u53ef\u89c6\u533a\u57df\uff0c\u5373\u9664\u53bb\u6d4f\u89c8\u5668\u7684\u90a3\u4e9b\u5de5\u5177\u680f\u72b6\u6001\u680f\u5269\u4e0b\u7684\u9875\u9762\u5c55\u793a\u7a7a\u95f4\u7684\u9ad8\u5ea6\uff1b<br \/>\u3000\u3000scrollHeight\uff1a\u5728IE\u4e0b\uff0cscrollHeight \u662f\u9875\u9762\u5b9e\u9645\u5185\u5bb9\u7684\u9ad8\u5ea6\uff0c\u53ef\u4ee5\u5c0f\u4e8eclientHeight\uff1b\u5728FF\u4e0b\uff0cscrollHeight \u662f\u7f51\u9875\u5185\u5bb9\u9ad8\u5ea6\uff0c\u4e0d\u8fc7\u6700\u5c0f\u503c\u662fclientHeight\u3002<br \/>\/*******************************************************\/<br \/>\u62d3\u5c55\u65b9\u6cd5\uff1a<br \/>1.\u5f39\u51fa\u786e\u8ba4\u6846\u56de\u8c03\u6267\u884c\u670d\u52a1\u5668\u7aef\u65b9\u6cd5<br \/><code>function ShowConfirm(title, content, target) \/\/\u663e\u793a\u786e\u8ba4\u5bf9\u8bdd\u6846<br \/>{&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;var pop = new Popup({<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contentType: 3,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isReloadOnClose: false,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 350,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height: 110<br \/>&nbsp;&nbsp;&nbsp;&nbsp;});<br \/>&nbsp;&nbsp;&nbsp;&nbsp;pop.setContent(\"title\", title);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;pop.setContent(\"confirmCon\", content);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;pop.setContent(\"callBack\", ShowCallBackServer); \/\/\u56de\u8c03\u51fd\u6570<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;pop.setContent(\"parameter\", {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id: \"divCall\",<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str: target,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;obj: pop<br \/>&nbsp;&nbsp;&nbsp;&nbsp;});<br \/>&nbsp;&nbsp;&nbsp;&nbsp;pop.build();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;pop.show();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;popp = pop;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return false;<br \/>}<br \/>\/\/\u6267\u884c\u670d\u52a1\u5668\u7aef\u65b9\u6cd5\uff0c\u5373\u8fdb\u884c__doPostBack('','')\u64cd\u4f5c<br \/>function ShowCallBackServer(para) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;var str = para[\"str\"];&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;if (\"\" != str && null != str) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str = GetEachBtnName(str);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (\"\" != str && null != str) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/alert(str);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;__doPostBack(str, '');<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp;&nbsp;&nbsp;ClosePop();<br \/>}<br \/>\/\/\u904d\u5386\u9875\u9762\u4e2d\u7684Button\u540d\u79f0<br \/>function GetEachBtnName(obj) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return obj.name == '' || obj.name == null ? obj.id : obj.name;<br \/>}<\/code><br \/>\u4f7f\u7528\u65b9\u6cd5\uff1a<br \/>\u3000\u3000\u5728\u4e00\u4e2a\u6709OnClick=&#8221;btnTest_Click&#8221; \u7684Button\u63a7\u4ef6\u4e0a\u6ce8\u518cOnClientClick\u4e3areturn ShowConfirm(&#8216; &#8216;,&#8217;\u662f\u5426\u786e\u5b9a\u5220\u9664\uff1f&#8217;,this)\u3002<br \/>\u5b8c\u6574\u4ee3\u7801\uff1a<br \/><code>&lt;asp:Button ID=\"btnDel\" runat=\"server\" Text=\"\u5220\u9664\" OnClick=\"btnDel_Click\"<br \/>&nbsp;&nbsp;&nbsp;&nbsp;OnClientClick=\"return ShowConfirm(' ','\u662f\u5426\u786e\u5b9a\u5220\u9664\uff1f',this)\" \/&gt;<\/code><\/p>\n<p>2.\u5728iframe\u4e2d\u4f7f\u7528popup.js<br \/>\u3000\u3000\u6211\u4eec\u5728\u4e00\u4e2a\u9875\u9762\u4e2d\u5185\u5d4c\u4e86\u4e00\u4e2aiframe\uff0c\u60f3\u8ba9iframe\u4e2d\u5f39\u51fa\u7684\u5bf9\u8bdd\u6846\u6216\u8005\u786e\u8ba4\u6846\u5728\u7236\u9875\u9762\u4e2d\u5f39\u51fa\u6765\uff0c\u5b9e\u73b0\u906e\u7f69\u5c42\u5168\u5c4f\u800c\u4e0d\u662f\u53ea\u662f\u5728iframe\u9875\u9762\u4e2d\u5168\u5c4f\uff0c\u7136\u540e\u786e\u8ba4\u540e\u6267\u884c\u56de\u8c03\u64cd\u4f5ciframe\uff0c\u53ef\u4ee5\u662f\u6267\u884ciframe\u4e2d\u7684\u670d\u52a1\u5668\u7aef\u65b9\u6cd5\u3002<br \/><code>function ShowConfirmIFrame(title, content, target) \/\/\u663e\u793a\u786e\u8ba4\u5bf9\u8bdd\u6846<br \/>{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;var pop = new Popup({<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contentType: 3,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isReloadOnClose: false,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width: 350,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height: 110<br \/>&nbsp;&nbsp;&nbsp;&nbsp;});<br \/>&nbsp;&nbsp;&nbsp;&nbsp;pop.setContent(\"title\", title);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;pop.setContent(\"confirmCon\", content);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;pop.setContent(\"callBack\", ShowIFrame); \/\/\u56de\u8c03\u51fd\u6570<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;pop.setContent(\"parameter\", {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id: \"divCall\",<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str: target,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;obj: pop<br \/>&nbsp;&nbsp;&nbsp;&nbsp;});<br \/>&nbsp;&nbsp;&nbsp;&nbsp;temp = target;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;pop.build();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;pop.show();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;popp = pop;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return false;<br \/>}<\/p>\n<p> var temp;<\/p>\n<p> function ShowIFrame() {<br \/>&nbsp;&nbsp;&nbsp;&nbsp; parent.frames[\"content\"].window.ShowCallBackServerIFrame(temp);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; \/\/&nbsp;&nbsp;&nbsp;&nbsp;parent.window.iframe.ShowCallBackServer();<br \/> }<\/p>\n<p>function ShowCallBackServerIFrame(para) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;var str = para;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;if (\"\" != str && null != str) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str = GetEachBtnName(str);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (\"\" != str && null != str) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;__doPostBack(str, '');<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp;&nbsp;&nbsp;closeWin();<br \/>}<\/code><br \/>\u4f7f\u7528\u65b9\u6cd5\uff1a<br \/>iframe\u4e2d\u5b9a\u4e49js\u65b9\u6cd5\uff1a<br \/><code>\/\/\u5220\u9664<br \/>&nbsp;&nbsp;function subDel(obj)<br \/>&nbsp;&nbsp;&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return parent.parentDel(obj);<br \/>&nbsp;&nbsp;&nbsp;&nbsp; }<\/code><br \/>Button\u6309\u94ae\u63a7\u4ef6\u6ce8\u518cOnClientClick\u4e8b\u4ef6\uff1a<br \/><code>&lt;asp:Button ID=\"btnDel\" runat=\"server\"&nbsp;&nbsp;OnClick=\"btnDel_Click\" ToolTip=\"\u5220\u9664\" CssClass=\"deleteBtn\" OnClientClick=\"return subDel(this);return false;\"&nbsp;&nbsp;\/&gt;<\/code><\/p>\n<p>\u7236\u9875\u9762\u5b9a\u4e49js\u65b9\u6cd5\uff1a<br \/><code>function parentDel(obj)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return ShowConfirmIFrame('\u5220\u9664','\u662f\u5426\u786e\u5b9a\u5220\u9664\uff1f',obj);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/code><\/p>\n<p>\u4e0b\u8f7d\uff1a<\/p>\n<p><a href=\"http:\/\/www.poloo.org\/wp-content\/attachments\/month_1004\/m2010414112840.rar\" target=\"_blank\">\u70b9\u51fb\u4e0b\u8f7d\u6b64\u6587\u4ef6<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u3000\u767e\u5ea6\u7a7a\u95f4\u7684\u5f39\u51fa\u7a97\u53e3\u548c\u62d6\u62fd\u6548\u679c(\u4e5f\u5c31\u662fpopup.js),\u4ee3\u7801\u7cbe\u7b80&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-334","post","type-post","status-publish","format-standard","hentry","category-Dream"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/334","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=334"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/334\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}