<?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>ls /proc &#187; javascript</title>
	<atom:link href="http://www.lsproc.com/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lsproc.com/blog</link>
	<description>lsproc.com</description>
	<lastBuildDate>Fri, 18 Nov 2011 09:22:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>复制到剪切板 - 兼容 ie, firefox, chrome &amp; flash10</title>
		<link>http://www.lsproc.com/blog/copy_to_clipboard/</link>
		<comments>http://www.lsproc.com/blog/copy_to_clipboard/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 06:48:44 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Program&Database]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.lsproc.com/blog/?p=397</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/copy_to_clipboard/ 从 discuz! 里扒出来的(简易实现), 代码如下: var clipboardswfdata; var setcopy_gettext = function(){ clipboardswfdata = document.getElementById(&#039;data&#039;).value; window.document.clipboardswf.SetVariable(&#039;str&#039;, clipboardswfdata); } var floatwin = function(){ alert(&#039;copy success, &#039; + clipboardswfdata); } &#60;input type=&#34;text&#34; name=&#34;data&#34; value=&#34;xxxxx11111&#34; id =&#34;data&#34; /&#62; &#60;div id=&#34;clipboard_content&#34;&#62; &#60;span class=&#34;clipinner&#34; &#8230; <a href="http://www.lsproc.com/blog/copy_to_clipboard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/copy_to_clipboard/">http://www.lsproc.com/blog/copy_to_clipboard/</a></p>
<p>从 discuz! 里扒出来的(简易实现), 代码如下:</p>
<pre class="brush: javascript">
var clipboardswfdata;

var setcopy_gettext = function(){
    clipboardswfdata = document.getElementById(&#039;data&#039;).value;
    window.document.clipboardswf.SetVariable(&#039;str&#039;, clipboardswfdata);
}

var floatwin = function(){
    alert(&#039;copy success, &#039; + clipboardswfdata);
}
</pre>
<pre class="brush: xhtml">
&lt;input type=&quot;text&quot; name=&quot;data&quot; value=&quot;xxxxx11111&quot; id =&quot;data&quot; /&gt;
&lt;div id=&quot;clipboard_content&quot;&gt;
&lt;span class=&quot;clipinner&quot; id=&quot;clipinner&quot;&gt;点此复制到剪贴板
&lt;embed name=&quot;clipboardswf&quot; class=&quot;clipboardswf&quot; id=&quot;clipboardswf&quot; onmouseover=&quot;setcopy_gettext()&quot; devicefont=&quot;false&quot; src=&quot;./clipboard.swf&quot; menu=&quot;false&quot; allowscriptaccess=&quot;sameDomain&quot; swliveconnect=&quot;true&quot; wmode=&quot;transparent&quot; type=&quot;application/x-shockwave-flash&quot; height=&quot;20&quot; width=&quot;100&quot;&gt;&lt;/span&gt;
&lt;/div&gt;
</pre>
<pre class="brush: css">
&lt;style type=&quot;text/css&quot;&gt;
body {font-size:12px;}
.clipinner {position:relative;}
.clipboardswf {position:absolute; left:0; top:0;}
&lt;/style&gt;
</pre>
<p>实现稍微有些恶心, 用 onmouseover 事件往 flash 中传递数据<br />
另: 没有对ie单独处理, ie中推荐使用 window.clipboardData</p>
<p>演示地址: <a href="http://www.lsproc.com/demo/clipboard/demo.html">http://www.lsproc.com/demo/cliboard/demo.html</a><br />
演示代码下载: http://www.lsproc.com/wiki/_media/snippets:clipboard.zip</p>
<p>另: google code 上有个 zeroclipboard 的项目, 如果想要方便的话, 也可以使用<br />
地址: <a href="http://code.google.com/p/zeroclipboard/">http://code.google.com/p/zeroclipboard/</a>
<p>-- EOF --</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>2009-01-08 -- <a href="http://www.lsproc.com/blog/ajax_char_lose/" title="Ajax 提交数据加号与连接符丢失">Ajax 提交数据加号与连接符丢失</a> (0)</li><li>2008-01-23 -- <a href="http://www.lsproc.com/blog/limit_textarea_length_by_js/" title="Js控制输入字符数限制">Js控制输入字符数限制</a> (0)</li><li>2008-01-12 -- <a href="http://www.lsproc.com/blog/auto_resize_images/" title="自动等比例缩放网页中的图片">自动等比例缩放网页中的图片</a> (0)</li><li>2007-05-13 -- <a href="http://www.lsproc.com/blog/html_or_xhtml/" title="HTML or XHTML, 关于web标准">HTML or XHTML, 关于web标准</a> (0)</li><li>2006-03-01 -- <a href="http://www.lsproc.com/blog/div-and-table-tags/" title="使用DIV之后,什么时候使用TABLE?">使用DIV之后,什么时候使用TABLE?</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/copy_to_clipboard/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Ajax 提交数据加号与连接符丢失</title>
		<link>http://www.lsproc.com/blog/ajax_char_lose/</link>
		<comments>http://www.lsproc.com/blog/ajax_char_lose/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 03:09:48 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Program&Database]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/?p=195</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/ajax_char_lose/ 采用Ajax传递数据时，通常会将数据整理为data="var1=abc&#038;var2=def"。而当数据中存在加号(+)或是连接符(&#038;)时，服务器端接收数据时会有部分数据丢失现象。分析一下Ajax传递数据的格式与Javascript的语法不难发现： 1. "+"号：JavaScript解析为字符串连接符，所以服务器端接收数据时"+"会丢失。 2. "&#038;"：JavaScript解析为变量连接符，所以服务器端接收数据时&#038;符号以后的数据都会丢失。 解决办法也相当简单，只需要为+与&#038;符号编码即可： function vchar(str) { str = str.replace(/\+/g, &#34;%2B&#34;); str = str.replace(/\&#38;/g, &#34;%26&#34;); return str; } var1 = &#34;abc+kef&#34;; var2 = &#34;abc&#38;kef&#34;; var1 = vchar(var1); var2 = vchar(var2); alert(var1); alert(var2); 使用jquery的话可以使用如下方式提交 var params &#8230; <a href="http://www.lsproc.com/blog/ajax_char_lose/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/ajax_char_lose/">http://www.lsproc.com/blog/ajax_char_lose/</a></p>
<p>采用Ajax传递数据时，通常会将数据整理为data="var1=abc&#038;var2=def"。而当数据中存在加号(+)或是连接符(&#038;)时，服务器端接收数据时会有部分数据丢失现象。分析一下Ajax传递数据的格式与Javascript的语法不难发现：</p>
<p>1. "+"号：JavaScript解析为字符串连接符，所以服务器端接收数据时"+"会丢失。</p>
<p>2. "&#038;"：JavaScript解析为变量连接符，所以服务器端接收数据时&#038;符号以后的数据都会丢失。</p>
<p>解决办法也相当简单，只需要为+与&#038;符号编码即可：</p>
<pre class="brush: javascript">
function vchar(str) {
    str = str.replace(/\+/g, &quot;%2B&quot;);
    str = str.replace(/\&amp;/g, &quot;%26&quot;);
    return str;
}
var1 = &quot;abc+kef&quot;;
var2 = &quot;abc&amp;kef&quot;;   

var1 = vchar(var1);
var2 = vchar(var2);   

alert(var1);
alert(var2);
</pre>
<p>使用jquery的话可以使用如下方式提交</p>
<pre class="brush: javascript">
var params = $(&#039;input, textarea&#039;).serialize();
$.ajax({
    type: &#039;post&#039;,
    url: &#039;xxxx.php&#039;,
    data: params,
    success: function(response){
        ......
    }
});
</pre>
<p>参考: http://www.phplamp.org/2008/11/javascript-ajax-char-lose/
<p>-- EOF --</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>2010-04-13 -- <a href="http://www.lsproc.com/blog/copy_to_clipboard/" title="复制到剪切板 &#8211; 兼容 ie, firefox, chrome &#038; flash10">复制到剪切板 &#8211; 兼容 ie, firefox, chrome &#038; flash10</a> (5)</li><li>2008-01-23 -- <a href="http://www.lsproc.com/blog/limit_textarea_length_by_js/" title="Js控制输入字符数限制">Js控制输入字符数限制</a> (0)</li><li>2008-01-12 -- <a href="http://www.lsproc.com/blog/auto_resize_images/" title="自动等比例缩放网页中的图片">自动等比例缩放网页中的图片</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/ajax_char_lose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Js控制输入字符数限制</title>
		<link>http://www.lsproc.com/blog/limit_textarea_length_by_js/</link>
		<comments>http://www.lsproc.com/blog/limit_textarea_length_by_js/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 06:20:47 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[WebDesign]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/limit_textarea_length_by_js/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/limit_textarea_length_by_js/ From: http://www.phpcake.cn/archives/26/ &#60;script type=&#34;text/javascript&#34;&#62; function ismaxlength(obj){ var mlength=obj.getAttribute? parseInt(obj.getAttribute(&#34;maxlength&#34;)) : &#34;&#34; if (obj.getAttribute &#38;&#38; obj.value.length&#62;mlength) obj.value=obj.value.substring(0,mlength) } &#60;/script&#62; &#60;textarea maxlength=&#34;10&#34; onkeyup=&#34;return ismaxlength(this)&#34;&#62;&#60;/textarea&#62; -- EOF -- Related Posts2010-04-13 -- 复制到剪切板 &#8211; 兼容 ie, firefox, chrome &#038; flash10 (5)2009-01-08 &#8230; <a href="http://www.lsproc.com/blog/limit_textarea_length_by_js/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/limit_textarea_length_by_js/">http://www.lsproc.com/blog/limit_textarea_length_by_js/</a></p>
<p>From: http://www.phpcake.cn/archives/26/</p>
<pre class="brush: javascript">
&lt;script type=&quot;text/javascript&quot;&gt;
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute(&quot;maxlength&quot;)) : &quot;&quot;
if (obj.getAttribute &amp;&amp; obj.value.length&gt;mlength)
obj.value=obj.value.substring(0,mlength)
}
&lt;/script&gt; 

&lt;textarea maxlength=&quot;10&quot; onkeyup=&quot;return ismaxlength(this)&quot;&gt;&lt;/textarea&gt;</pre>
<p>-- EOF --</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>2010-04-13 -- <a href="http://www.lsproc.com/blog/copy_to_clipboard/" title="复制到剪切板 &#8211; 兼容 ie, firefox, chrome &#038; flash10">复制到剪切板 &#8211; 兼容 ie, firefox, chrome &#038; flash10</a> (5)</li><li>2009-01-08 -- <a href="http://www.lsproc.com/blog/ajax_char_lose/" title="Ajax 提交数据加号与连接符丢失">Ajax 提交数据加号与连接符丢失</a> (0)</li><li>2008-01-12 -- <a href="http://www.lsproc.com/blog/auto_resize_images/" title="自动等比例缩放网页中的图片">自动等比例缩放网页中的图片</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/limit_textarea_length_by_js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>自动等比例缩放网页中的图片</title>
		<link>http://www.lsproc.com/blog/auto_resize_images/</link>
		<comments>http://www.lsproc.com/blog/auto_resize_images/#comments</comments>
		<pubDate>Sat, 12 Jan 2008 07:34:14 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[WebDesign]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[网页设计]]></category>

		<guid isPermaLink="false">http://www.lostk.com/blog/auto_resize_images/</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/auto_resize_images/ resizeimg.js window.onload = function() { for (var index = 0; index &#60; document.images.length; index++) { var widthRestriction = 400; var heightRestriction = 400; var rate = document.images[index].width / document.images[index].height; if (document.images[index].width &#62; widthRestriction) { document.images[index].width = widthRestriction; &#8230; <a href="http://www.lsproc.com/blog/auto_resize_images/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/auto_resize_images/">http://www.lsproc.com/blog/auto_resize_images/</a></p>
<p>resizeimg.js</p>
<pre class="brush: javascript">
window.onload = function() {

    for (var index = 0; index &lt; document.images.length; index++) {

        var widthRestriction = 400;
        var heightRestriction = 400;
        var rate = document.images[index].width / document.images[index].height;

        if (document.images[index].width &gt; widthRestriction) {
            document.images[index].width = widthRestriction;
            document.images[index].height = widthRestriction / rate;
        } else if (document.images[index].height &gt; heightRestriction) {
            document.images[index].height = heightRestriction;
            document.images[index].width = heightRestriction * rate;
        }

        document.images[index].onclick = function() {window.open(this.src)};
        document.images[index].title = document.images[index].title + &#039; 点击在新窗口中查看原图&#039;;
    }
}
</pre>
<p>-- EOF --</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li>2010-04-13 -- <a href="http://www.lsproc.com/blog/copy_to_clipboard/" title="复制到剪切板 &#8211; 兼容 ie, firefox, chrome &#038; flash10">复制到剪切板 &#8211; 兼容 ie, firefox, chrome &#038; flash10</a> (5)</li><li>2009-01-08 -- <a href="http://www.lsproc.com/blog/ajax_char_lose/" title="Ajax 提交数据加号与连接符丢失">Ajax 提交数据加号与连接符丢失</a> (0)</li><li>2008-01-23 -- <a href="http://www.lsproc.com/blog/limit_textarea_length_by_js/" title="Js控制输入字符数限制">Js控制输入字符数限制</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/auto_resize_images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

