iframe自适应
iframeids数组为要进行自适应的所有iframe。<br><br>在body里加入onload<br><br><div id="codeText" class="codeText"><ol style="margin: 0pt 1px 0pt 0pt; padding: 5px 0pt;" start="1" class="dp-css"><li><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 204);"><</span><span style="color: rgb(255, 0, 0);">script</span> <span style="color: rgb(255, 0, 0);">type</span><span style="color: rgb(0, 0, 204);">=</span><span style="color: rgb(255, 0, 255);">"text/javascript"</span><span style="color: rgb(0, 0, 204);">></span><br></span></li><li><span style="color: rgb(0, 0, 255);">var</span> iframeids<span style="color: rgb(0, 0, 204);">=</span><span style="color: rgb(0, 0, 204);">[</span><span style="color: rgb(255, 0, 255);">"topframe"</span><span style="color: rgb(0, 0, 204);">,</span><span style="color: rgb(255, 0, 255);">"rightframe"</span><span style="color: rgb(0, 0, 204);">,</span><span style="color: rgb(255, 0, 255);">"bottomframe"</span><span style="color: rgb(0, 0, 204);">]</span><br></li><li>
<span style="color: rgb(0, 0, 255);">function</span> dyniframesize<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">{</span><br></li><li>
<span style="color: rgb(0, 0, 255);">var</span> pTar <span style="color: rgb(0, 0, 204);">=</span> <span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<span style="color: rgb(0, 0, 255);">for</span> <span style="color: rgb(0, 0, 204);">(</span>i<span style="color: rgb(0, 0, 204);">=</span>0<span style="color: rgb(0, 0, 204);">;</span> i<span style="color: rgb(0, 0, 204);"><</span>iframeids<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">length</span><span style="color: rgb(0, 0, 204);">;</span> i<span style="color: rgb(0, 0, 204);">+</span><span style="color: rgb(0, 0, 204);">+</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">{</span><br></li><li>
<span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(255, 0, 0);">document</span><span style="color: rgb(0, 0, 204);">.</span>getElementByIdx<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">{</span><br></li><li>
pTar <span style="color: rgb(0, 0, 204);">=</span> <span style="color: rgb(255, 0, 0);">document</span><span style="color: rgb(0, 0, 204);">.</span>getElementByIdx<span style="color: rgb(0, 0, 204);">(</span>iframeids<span style="color: rgb(0, 0, 204);">[</span>i<span style="color: rgb(0, 0, 204);">]</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<span style="color: rgb(0, 0, 204);">}</span><br></li><li>
<span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 204);">{</span><br></li><li>
eval_r<span style="color: rgb(0, 0, 204);">(</span><span style="color: rgb(255, 0, 255);">'pTar = '</span> <span style="color: rgb(0, 0, 204);">+</span> iframeids<span style="color: rgb(0, 0, 204);">[</span>i<span style="color: rgb(0, 0, 204);">]</span> <span style="color: rgb(0, 0, 204);">+</span> <span style="color: rgb(255, 0, 255);">';'</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<span style="color: rgb(0, 0, 204);">}</span><br></li><li>
<span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 204);">(</span>pTar <span style="color: rgb(0, 0, 204);">&</span><span style="color: rgb(0, 0, 204);">&</span> <span style="color: rgb(0, 0, 204);">!</span><span style="color: rgb(255, 0, 0);">window</span><span style="color: rgb(0, 0, 204);">.</span>opera<span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">{</span><br></li><li>
pTar<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">style</span><span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">display</span><span style="color: rgb(0, 0, 204);">=</span><span style="color: rgb(255, 0, 255);">"block"</span><br></li><li>
<span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 204);">(</span>pTar<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">contentDocument</span> <span style="color: rgb(0, 0, 204);">&</span><span style="color: rgb(0, 0, 204);">&</span> pTar<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">contentDocument</span><span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">body</span><span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">offsetHeight</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">{</span><br></li><li>
pTar<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">height</span> <span style="color: rgb(0, 0, 204);">=</span> pTar<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">contentDocument</span><span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">body</span><span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">offsetHeight</span><span style="color: rgb(0, 0, 204);">+</span>10<span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<span style="color: rgb(0, 0, 204);">}</span><br></li><li>
<span style="color: rgb(0, 0, 255);">else</span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 204);">(</span>pTar<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">Document</span> <span style="color: rgb(0, 0, 204);">&</span><span style="color: rgb(0, 0, 204);">&</span> pTar<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">Document</span><span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">body</span><span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">scrollHeight</span><span style="color: rgb(0, 0, 204);">)</span><span style="color: rgb(0, 0, 204);">{</span><br></li><li>
pTar<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">width</span> <span style="color: rgb(0, 0, 204);">=</span> pTar<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">Document</span><span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">body</span><span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">scrollWidth</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
pTar<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">height</span> <span style="color: rgb(0, 0, 204);">=</span> pTar<span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">Document</span><span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">body</span><span style="color: rgb(0, 0, 204);">.</span><span style="color: rgb(255, 0, 0);">scrollHeight</span><span style="color: rgb(0, 0, 204);">;</span><br></li><li>
<br></li><li>
<span style="color: rgb(0, 0, 204);">}</span><br></li><li>
<span style="color: rgb(0, 0, 204);">}</span><br></li><li>
<span style="color: rgb(0, 0, 204);">}</span><br></li><li>
<span style="color: rgb(0, 0, 204);">}</span><br></li><li>
<span style="color: rgb(0, 0, 204);"><</span><span style="color: rgb(0, 0, 204);">/</span><span style="color: rgb(255, 0, 0);">script</span><span style="color: rgb(0, 0, 204);">></span></li></ol></div>
页:
[1]