<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Acroidea &#187; JavaScript</title>
	<atom:link href="http://www.acroidea.com/index.php/category/program/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.acroidea.com</link>
	<description></description>
	<lastBuildDate>Wed, 18 Aug 2010 10:33:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Jquery UI Dialog 无法提交服务器解决方法</title>
		<link>http://www.acroidea.com/index.php/2010/08/12/jquery-ui-dialog-can-not-submit-to-server/</link>
		<comments>http://www.acroidea.com/index.php/2010/08/12/jquery-ui-dialog-can-not-submit-to-server/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 11:01:12 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Dialog]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.acroidea.com/?p=488</guid>
		<description><![CDATA[Jquery UI 库中的 Dialog 控件里如果存在表单，是无法直接提交到服务器的，因为在jquery.ui.dialog.js文件中（1.8.2版本中大概是在59行的位置）有这样的代码： [javascript] uiDialog = (self.uiDialog = $(&#8221;)) .appendTo(document.body) .hide() .addClass(uiDialogClasses + options.dialogClass) .css({ zIndex: options.zIndex })...]]></description>
			<content:encoded><![CDATA[<p>Jquery UI 库中的 Dialog 控件里如果存在表单，是无法直接提交到服务器的，因为在jquery.ui.dialog.js文件中（1.8.2版本中大概是在59行的位置）有这样的代码：<br />
[javascript]<br />
uiDialog = (self.uiDialog = $(&#8221;))<br />
.appendTo(document.body)<br />
.hide()<br />
.addClass(uiDialogClasses + options.dialogClass)<br />
.css({<br />
zIndex: options.zIndex<br />
})<br />
// setting tabIndex makes the div focusable<br />
// setting outline to 0 prevents a border on focus in Mozilla<br />
.attr(&#8216;tabIndex&#8217;, -1).css(&#8216;outline&#8217;, 0).keydown(function(event) {<br />
if (options.closeOnEscape &amp;&amp; event.keyCode &amp;&amp;<br />
event.keyCode === $.ui.keyCode.ESCAPE) {</p>
<p>self.close(event);<br />
event.preventDefault();<br />
}<br />
})<br />
[/javascript]<br />
也就是说被创建的dialog元素是被添加到body元素中了，你想dialog的内容被作为子元素添加在了它所创建的这个dialog元素里，自然也会被从原始的form元素中拿出来了，这样它里面的表单元素也就无法知道自己提交到哪去了。</p>
<p>解决方法：<br />
有人可能想直接修改上面这段代码，把.appendTo(document.body)改为类似.appendTo(document.forms[0])这样的代码。不过不管怎么说修改jquery这么成熟的库总不是明智的作法。我个人是在调用了dialog()方法后再将生成的元素放入到form中。<br />
例如：<br />
[javascript]<br />
$(&#8216;#control_panel_dialog&#8217;).dialog();<br />
$(&#8220;body>div[role=dialog]&#8220;).appendTo(&#8216;form:first&#8217;);<br />
[/javascript]<br />
或者：<br />
[javascript]<br />
$(&#8216;#control_panel_dialog&#8217;).dialog().parent().appendTo(&#8216;form:first&#8217;);<br />
[/javascript]<br />
或者：<br />
[javascript]<br />
$(&#8216;#control_panel_dialog&#8217;).dialog();<br />
$(&#8216;.ui-dialog&#8217;).appendTo(&#8216;form:first&#8217;);<br />
[/javascript]<br />
由于我正常是使用asp.net，正常只有一个 form 元素，这样的话直接加入到 &#8216;form:first&#8217; 就好了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.acroidea.com/index.php/2010/08/12/jquery-ui-dialog-can-not-submit-to-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get viewport size (width and height) with javascript</title>
		<link>http://www.acroidea.com/index.php/2009/08/18/get-viewport-size-width-and-height-with-javascript/</link>
		<comments>http://www.acroidea.com/index.php/2009/08/18/get-viewport-size-width-and-height-with-javascript/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 05:41:39 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.acroidea.com/?p=207</guid>
		<description><![CDATA[&#60;script type=&#34;text/javascript&#34;&#62; &#60;!-- var viewportwidth; var viewportheight; // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight if (typeof...]]></description>
			<content:encoded><![CDATA[<p><pre><pre lang="javascript">
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--

 var viewportwidth;
 var viewportheight;

 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

 if (typeof window.innerWidth != &#039;undefined&#039;)
 {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;viewportwidth = window.innerWidth,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;viewportheight = window.innerHeight
 }

// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != &#039;undefined&#039;
&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; typeof document.documentElement.clientWidth !=
&nbsp;&nbsp;&nbsp;&nbsp; &#039;undefined&#039; &amp;&amp; document.documentElement.clientWidth != 0)
 {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; viewportwidth = document.documentElement.clientWidth,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; viewportheight = document.documentElement.clientHeight
 }

 // older versions of IE

 else
 {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; viewportwidth = document.getElementsByTagName(&#039;body&#039;)[0].clientWidth,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; viewportheight = document.getElementsByTagName(&#039;body&#039;)[0].clientHeight
 }
document.write(&#039;&lt;p&gt;Your viewport width is &#039;+viewportwidth+&#039;x&#039;+viewportheight+&#039;&lt;/p&gt;&#039;);
//--&gt;
&lt;/script&gt;
</pre></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.acroidea.com/index.php/2009/08/18/get-viewport-size-width-and-height-with-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Javascript 获取窗口宽度和高度值</title>
		<link>http://www.acroidea.com/index.php/2009/04/05/javascript-window-width-height/</link>
		<comments>http://www.acroidea.com/index.php/2009/04/05/javascript-window-width-height/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 14:39:59 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.acroidea.com/?p=166</guid>
		<description><![CDATA[获取页面高度，窗口高度，滚动条高度等参数值： function getPageScroll(){ var yScroll; if (self.pageYOffset) { yScroll = self.pageYOffset; } else if (document.documentElement &#38;&#38; document.documentElement.scrollTop){   // Explorer 6...]]></description>
			<content:encoded><![CDATA[<h4>获取页面高度，窗口高度，滚动条高度等参数值：</h4>
<div class="code lCode lCode2">
<ol>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="k1">function</span> getPageScroll(){</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="k1">var</span> yScroll;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="k1">if</span> (self.pageYOffset) {</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> yScroll = self.pageYOffset;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> } <span class="k1">else</span> <span class="k1">if</span> (<span class="k2">document</span>.documentElement &amp;&amp; <span class="k2">document</span>.documentElement.scrollTop){   <span class="s2">// Explorer 6 Strict</span></li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> yScroll = <span class="k2">document</span>.documentElement.scrollTop;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> } <span class="k1">else</span> <span class="k1">if</span> (<span class="k2">document</span>.body) {<span class="s2">// all other Explorers</span></li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> yScroll = <span class="k2">document</span>.body.scrollTop;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> }</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> arrayPageScroll = <span class="k1">new</span> <span class="k2">Array</span>(&#8221;,yScroll)</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="k1">return</span> arrayPageScroll;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);">}</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"><span class="k1">function</span> getPageSize(){</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="k1">var</span> xScroll, yScroll;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="k1">if</span> (<span class="k2">window</span>.innerHeight &amp;&amp; <span class="k2">window</span>.scrollMaxY) {</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> xScroll = <span class="k2">document</span>.body.scrollWidth;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> yScroll = <span class="k2">window</span>.innerHeight + <span class="k2">window</span>.scrollMaxY;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> } <span class="k1">else</span> <span class="k1">if</span> (<span class="k2">document</span>.body.scrollHeight &gt; <span class="k2">document</span>.body.offsetHeight){ <span class="s2">// all but Explorer Mac</span></li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> xScroll = <span class="k2">document</span>.body.scrollWidth;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> yScroll = <span class="k2">document</span>.body.scrollHeight;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> } <span class="k1">else</span> { <span class="s2">// Explorer Mac&#8230;would also work in Explorer 6 Strict, Mozilla and Safari</span></li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> xScroll = <span class="k2">document</span>.body.offsetWidth;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> yScroll = <span class="k2">document</span>.body.offsetHeight;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> }</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="k1">var</span> windowWidth, windowHeight;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="k1">if</span> (self.innerHeight) {  <span class="s2">// all except Explorer</span></li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> windowWidth = self.innerWidth;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> windowHeight = self.innerHeight;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> } <span class="k1">else</span> <span class="k1">if</span> (<span class="k2">document</span>.documentElement &amp;&amp; <span class="k2">document</span>.documentElement.clientHeight) { <span class="s2">// Explorer 6 Strict Mode</span></li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> windowWidth = <span class="k2">document</span>.documentElement.clientWidth;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> windowHeight = <span class="k2">document</span>.documentElement.clientHeight;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> } <span class="k1">else</span> <span class="k1">if</span> (<span class="k2">document</span>.body) { <span class="s2">// other Explorers</span></li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> windowWidth = <span class="k2">document</span>.body.clientWidth;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> windowHeight = <span class="k2">document</span>.body.clientHeight;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> }</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"></li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="s2">// for small pages with total height less then height of the viewport</span></li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="k1">if</span>(yScroll &lt; windowHeight){</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> pageHeight = windowHeight;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> } <span class="k1">else</span> {</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> pageHeight = yScroll;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> }</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="k1">if</span>(xScroll &lt; windowWidth){</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> pageWidth = windowWidth;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> } <span class="k1">else</span> {</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> pageWidth = xScroll;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> }</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> arrayPageSize = <span class="k1">new</span> <span class="k2">Array</span>(pageWidth,pageHeight,windowWidth,windowHeight)</li>
<li class="hover" onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);"> <span class="k1">return</span> arrayPageSize;</li>
<li onmouseover="lCC.mousehover(this);" onmouseout="lCC.mouseout(this);">}</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.acroidea.com/index.php/2009/04/05/javascript-window-width-height/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
