JavaScript Jquery各种代码片段
程序员文章站
2022-06-13 17:03:20
...
[javascript]
<span style="color:rgb(102,102,102);
font-size:14px;
line-height:15px;
background-color:rgb(192,208,246)"></span><div class="wp_syntax"><div class="code"><pre class="javascript" style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-right:0px;
padding-bottom:0px;
padding-left:20px;
font-family:monospace;
word-wrap:break-word;
overflow-x:auto;
border-left-width:5px;
border-left-style:solid;
border-left-color:rgb(221,221,221);
font-size:12px;
line-height:21px;
color:rgb(102,102,102);
background-color:rgb(245,245,245)" name="code"><span style="color:rgb(0,51,102)"><strong>var</strong></span> adjustIframe <span style="color:rgb(51,153,51)">=</span> <span style="color:rgb(0,51,102)"><strong>function</strong></span> <span style="color:rgb(0,153,0)">(</span>id<span style="color:rgb(0,153,0)">)</span> <span style="color:rgb(0,153,0)">{</span>
<span style="color:rgb(0,51,102)"><strong>var</strong></span> iframe <span style="color:rgb(51,153,51)">=</span> document.<span style="color:rgb(102,0,102)">getElementById</span><span style="color:rgb(0,153,0)">(</span>id<span style="color:rgb(0,153,0)">)</span>
<span style="color:rgb(0,51,102)"><strong>var</strong></span> idoc <span style="color:rgb(51,153,51)">=</span> iframe.<span style="color:rgb(102,0,102)">contentWindow</span> <span style="color:rgb(51,153,51)">&&</span> iframe.<span style="color:rgb(102,0,102)">contentWindow</span>.<span style="color:rgb(102,0,102)">document</span> <span style="color:rgb(51,153,51)">||</span> iframe.<span style="color:rgb(102,0,102)">contentDocument</span><span style="color:rgb(51,153,51)">;
</span>
<span style="color:rgb(0,51,102)"><strong>var</strong></span> callback <span style="color:rgb(51,153,51)">=</span> <span style="color:rgb(0,51,102)"><strong>function</strong></span> <span style="color:rgb(0,153,0)">(</span><span style="color:rgb(0,153,0)">)</span> <span style="color:rgb(0,153,0)">{</span>
<span style="color:rgb(0,51,102)"><strong>var</strong></span> iheight <span style="color:rgb(51,153,51)">=</span> Math.<span style="color:rgb(102,0,102)">max</span><span style="color:rgb(0,153,0)">(</span>idoc.<span style="color:rgb(102,0,102)">body</span>.<span style="color:rgb(102,0,102)">scrollHeight</span><span style="color:rgb(51,153,51)">,</span> idoc.<span style="color:rgb(102,0,102)">documentElement</span>.<span style="color:rgb(102,0,102)">scrollHeight</span><span style="color:rgb(0,153,0)">)</span><span style="color:rgb(51,153,51)">;
</span> <span style="color:rgb(0,102,0)"><em>
//取得其高</em></span>
iframe.<span style="color:rgb(102,0,102)">style</span>.<span style="color:rgb(102,0,102)">height</span> <span style="color:rgb(51,153,51)">=</span> iheight <span style="color:rgb(51,153,51)">+</span> <span style="color:rgb(51,102,204)">"px"</span><span style="color:rgb(51,153,51)">;
</span>
<span style="color:rgb(0,153,0)">}</span>
<span style="color:rgb(0,0,102)"><strong>if</strong></span> <span style="color:rgb(0,153,0)">(</span>iframe.<span style="color:rgb(102,0,102)">attachEvent</span><span style="color:rgb(0,153,0)">)</span> <span style="color:rgb(0,153,0)">
{</span>
iframe.<span style="color:rgb(102,0,102)">attachEvent</span><span style="color:rgb(0,153,0)">(</span><span style="color:rgb(51,102,204)">"onload"</span><span style="color:rgb(51,153,51)">,</span> callback<span style="color:rgb(0,153,0)">)</span><span style="color:rgb(51,153,51)">;
</span>
<span style="color:rgb(0,153,0)">}</span> <span style="color:rgb(0,0,102)"><strong>else</strong></span> <span style="color:rgb(0,153,0)">{</span>
iframe.<span style="color:rgb(0,0,102)">onload</span> <span style="color:rgb(51,153,51)">=</span> callback
<span style="color:rgb(0,153,0)">}</span>
<span style="color:rgb(0,153,0)">}</span></pre><div><span style="color:rgb(0,153,0)"><br></span></div></div></div><p style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-bottom:0px;
line-height:25px;
color:rgb(102,102,102)"><span id="more-664"></span></p><div class="post-top" style="background-color:initial;
padding-left:115px"></div>
[javascript]
<span style="background-color:rgb(192,208,246)"></span><span style="color:rgb(102,102,102);
font-size:14px;
line-height:15px;
background-color:rgb(192,208,246)">HTML代码如下所示:</span><p style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-bottom:0px;
line-height:25px;
color:rgb(102,102,102)"></p><div class="wp_syntax"><div class="code"><pre class="html" style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-right:0px;
padding-bottom:0px;
padding-left:20px;
font-family:monospace;
word-wrap:break-word;
overflow-x:auto;
border-left-width:5px;
border-left-style:solid;
border-left-color:rgb(221,221,221);
font-size:12px;
line-height:21px;
color:rgb(102,102,102)" name="code"><iframe id="js_sub_web" width="80%" frameborder="0" scrolling="no" allowTransparency="true" src="http://www.cnblogs.com/rubylouvre/archive/2009/09/15/1566722.html">
</iframe></pre></div></div><p style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-bottom:0px;
line-height:25px;
color:rgb(102,102,102)">使用代码:</p><div class="wp_syntax"><div class="code"><pre class="javascript" style="margin-top:15px;
margin-bottom:15px;
padding-top:0px; padding-right:0px;
padding-bottom:0px; padding-left:20px;
font-family:monospace;
word-wrap:break-word;
overflow-x:auto;
border-left-width:5px;
border-left-style:solid;
border-left-color:rgb(221,221,221);
font-size:12px; line-height:21px;
color:rgb(102,102,102);
background-color:rgb(245,245,245)" name="code">window.<span style="color:rgb(0,0,102)">onload</span> <span style="color:rgb(51,153,51)">=</span> <span style="color:rgb(0,51,102)"><strong>function</strong></span><span style="color:rgb(0,153,0)">(</span><span style="color:rgb(0,153,0)">)</span><span style="color:rgb(0,153,0)">{</span>
adjustIframe<span style="color:rgb(0,153,0)">(</span><span style="color:rgb(51,102,204)">"js_sub_web"</span><span style="color:rgb(0,153,0)">)</span><span style="color:rgb(51,153,51)">;</span>
<span style="color:rgb(0,153,0)">}</span></pre></div></div><div class="wp_syntax"><div class="code"><pre class="javascript" style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-right:0px;
padding-bottom:0px;
padding-left:20px;
word-wrap:break-word;
overflow-x:auto; border-left-width:5px;
border-left-style:solid; border-left-color:rgb(221,221,221)" name="code"></pre></div></div><span style="color:#666666"><span style="line-height:21px"></span></span>
<span style="color:rgb(102,102,102);
font-size:14px;
line-height:15px;
background-color:rgb(192,208,246)"></span><div class="wp_syntax"><div class="code"><pre class="javascript" style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-right:0px;
padding-bottom:0px;
padding-left:20px;
font-family:monospace;
word-wrap:break-word;
overflow-x:auto;
border-left-width:5px;
border-left-style:solid;
border-left-color:rgb(221,221,221);
font-size:12px;
line-height:21px;
color:rgb(102,102,102);
background-color:rgb(245,245,245)" name="code"><span style="color:rgb(0,51,102)"><strong>var</strong></span> adjustIframe <span style="color:rgb(51,153,51)">=</span> <span style="color:rgb(0,51,102)"><strong>function</strong></span> <span style="color:rgb(0,153,0)">(</span>id<span style="color:rgb(0,153,0)">)</span> <span style="color:rgb(0,153,0)">{</span>
<span style="color:rgb(0,51,102)"><strong>var</strong></span> iframe <span style="color:rgb(51,153,51)">=</span> document.<span style="color:rgb(102,0,102)">getElementById</span><span style="color:rgb(0,153,0)">(</span>id<span style="color:rgb(0,153,0)">)</span>
<span style="color:rgb(0,51,102)"><strong>var</strong></span> idoc <span style="color:rgb(51,153,51)">=</span> iframe.<span style="color:rgb(102,0,102)">contentWindow</span> <span style="color:rgb(51,153,51)">&&</span> iframe.<span style="color:rgb(102,0,102)">contentWindow</span>.<span style="color:rgb(102,0,102)">document</span> <span style="color:rgb(51,153,51)">||</span> iframe.<span style="color:rgb(102,0,102)">contentDocument</span><span style="color:rgb(51,153,51)">;
</span>
<span style="color:rgb(0,51,102)"><strong>var</strong></span> callback <span style="color:rgb(51,153,51)">=</span> <span style="color:rgb(0,51,102)"><strong>function</strong></span> <span style="color:rgb(0,153,0)">(</span><span style="color:rgb(0,153,0)">)</span> <span style="color:rgb(0,153,0)">{</span>
<span style="color:rgb(0,51,102)"><strong>var</strong></span> iheight <span style="color:rgb(51,153,51)">=</span> Math.<span style="color:rgb(102,0,102)">max</span><span style="color:rgb(0,153,0)">(</span>idoc.<span style="color:rgb(102,0,102)">body</span>.<span style="color:rgb(102,0,102)">scrollHeight</span><span style="color:rgb(51,153,51)">,</span> idoc.<span style="color:rgb(102,0,102)">documentElement</span>.<span style="color:rgb(102,0,102)">scrollHeight</span><span style="color:rgb(0,153,0)">)</span><span style="color:rgb(51,153,51)">;
</span> <span style="color:rgb(0,102,0)"><em>
//取得其高</em></span>
iframe.<span style="color:rgb(102,0,102)">style</span>.<span style="color:rgb(102,0,102)">height</span> <span style="color:rgb(51,153,51)">=</span> iheight <span style="color:rgb(51,153,51)">+</span> <span style="color:rgb(51,102,204)">"px"</span><span style="color:rgb(51,153,51)">;
</span>
<span style="color:rgb(0,153,0)">}</span>
<span style="color:rgb(0,0,102)"><strong>if</strong></span> <span style="color:rgb(0,153,0)">(</span>iframe.<span style="color:rgb(102,0,102)">attachEvent</span><span style="color:rgb(0,153,0)">)</span> <span style="color:rgb(0,153,0)">
{</span>
iframe.<span style="color:rgb(102,0,102)">attachEvent</span><span style="color:rgb(0,153,0)">(</span><span style="color:rgb(51,102,204)">"onload"</span><span style="color:rgb(51,153,51)">,</span> callback<span style="color:rgb(0,153,0)">)</span><span style="color:rgb(51,153,51)">;
</span>
<span style="color:rgb(0,153,0)">}</span> <span style="color:rgb(0,0,102)"><strong>else</strong></span> <span style="color:rgb(0,153,0)">{</span>
iframe.<span style="color:rgb(0,0,102)">onload</span> <span style="color:rgb(51,153,51)">=</span> callback
<span style="color:rgb(0,153,0)">}</span>
<span style="color:rgb(0,153,0)">}</span></pre><div><span style="color:rgb(0,153,0)"><br></span></div></div></div><p style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-bottom:0px;
line-height:25px;
color:rgb(102,102,102)"><span id="more-664"></span></p><div class="post-top" style="background-color:initial;
padding-left:115px"></div>
[javascript]
<span style="background-color:rgb(192,208,246)"></span><span style="color:rgb(102,102,102);
font-size:14px;
line-height:15px;
background-color:rgb(192,208,246)">HTML代码如下所示:</span><p style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-bottom:0px;
line-height:25px;
color:rgb(102,102,102)"></p><div class="wp_syntax"><div class="code"><pre class="html" style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-right:0px;
padding-bottom:0px;
padding-left:20px;
font-family:monospace;
word-wrap:break-word;
overflow-x:auto;
border-left-width:5px;
border-left-style:solid;
border-left-color:rgb(221,221,221);
font-size:12px;
line-height:21px;
color:rgb(102,102,102)" name="code"><iframe id="js_sub_web" width="80%" frameborder="0" scrolling="no" allowTransparency="true" src="http://www.cnblogs.com/rubylouvre/archive/2009/09/15/1566722.html">
</iframe></pre></div></div><p style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-bottom:0px;
line-height:25px;
color:rgb(102,102,102)">使用代码:</p><div class="wp_syntax"><div class="code"><pre class="javascript" style="margin-top:15px;
margin-bottom:15px;
padding-top:0px; padding-right:0px;
padding-bottom:0px; padding-left:20px;
font-family:monospace;
word-wrap:break-word;
overflow-x:auto;
border-left-width:5px;
border-left-style:solid;
border-left-color:rgb(221,221,221);
font-size:12px; line-height:21px;
color:rgb(102,102,102);
background-color:rgb(245,245,245)" name="code">window.<span style="color:rgb(0,0,102)">onload</span> <span style="color:rgb(51,153,51)">=</span> <span style="color:rgb(0,51,102)"><strong>function</strong></span><span style="color:rgb(0,153,0)">(</span><span style="color:rgb(0,153,0)">)</span><span style="color:rgb(0,153,0)">{</span>
adjustIframe<span style="color:rgb(0,153,0)">(</span><span style="color:rgb(51,102,204)">"js_sub_web"</span><span style="color:rgb(0,153,0)">)</span><span style="color:rgb(51,153,51)">;</span>
<span style="color:rgb(0,153,0)">}</span></pre></div></div><div class="wp_syntax"><div class="code"><pre class="javascript" style="margin-top:15px;
margin-bottom:15px;
padding-top:0px;
padding-right:0px;
padding-bottom:0px;
padding-left:20px;
word-wrap:break-word;
overflow-x:auto; border-left-width:5px;
border-left-style:solid; border-left-color:rgb(221,221,221)" name="code"></pre></div></div><span style="color:#666666"><span style="line-height:21px"></span></span>
推荐阅读
-
JavaScript编程开发中高效jquery代码的19条写作指南
-
JavaScript 开发中移动节点的jquery代码
-
javascript和jQuery中的AJAX技术详解【包含AJAX各种跨域技术】
-
JavaScript开发中利用jQuery将多条数据插入模态框的示例代码
-
javascript用createRange拷贝Range片段到粘贴板(代码实例)
-
JavaScript用JQuery呼叫Server端方法教程示例代码
-
常用的几个JQuery代码片段
-
15个非常实用的JavaScript代码片段
-
工作中常用的js、jquery自定义扩展函数代码片段汇总
-
JavaScript实现各种排序的代码详解