javascript 打开窗户
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 打开窗户相关的知识,希望对你有一定的参考价值。
<span style="color: #003366; font-weight: bold;">function</span> open_window<span style="color: #66cc66;">(</span>url<span style="color: #66cc66;">)</span><span style="color: #66cc66;">{</span>
<span style="color: #003366; font-weight: bold;">var</span> wparams = <span style="color: #3366CC;">'toolbar=0,location=0,directories=0,status=0,menubar=0,'</span>;
wparams += <span style="color: #3366CC;">'scrollbars=0,resizable=0,width=280,height=150'</span>;
<span style="color: #003366; font-weight: bold;">var</span> window = window.<span style="color: #000066;">open</span><span style="color: #66cc66;">(</span>url, <span style="color: #3366CC;">'window_name'</span>, wparams<span style="color: #66cc66;">)</span>;
window.<span style="color: #000066;">focus</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>
<span style="color: #003366; font-weight: bold;">function</span> create_window<span style="color: #66cc66;">(</span>content<span style="color: #66cc66;">)</span><span style="color: #66cc66;">{</span>
<span style="color: #003366; font-weight: bold;">var</span> wparams = <span style="color: #3366CC;">'toolbar=0,location=0,directories=0,status=0,menubar=0,'</span>;
wparams += <span style="color: #3366CC;">'scrollbars=0,resizable=0,width=280,height=150'</span>;
<span style="color: #003366; font-weight: bold;">var</span> window = window.<span style="color: #000066;">open</span><span style="color: #66cc66;">(</span><span style="color: #3366CC;">''</span>, <span style="color: #3366CC;">'window_name'</span>, wparams<span style="color: #66cc66;">)</span>;
window.<span style="color: #006600;">document</span>.<span style="color: #000066;">open</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #000066; font-weight: bold;">with</span><span style="color: #66cc66;">(</span>window.<span style="color: #006600;">document</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">{</span>
<span style="color: #000066; font-weight: bold;">write</span><span style="color: #66cc66;">(</span>content<span style="color: #66cc66;">)</span>;
<span style="color: #000066; font-weight: bold;">write</span><span style="color: #66cc66;">(</span><span style="color: #3366CC;">"<br/>"</span><span style="color: #66cc66;">)</span>;
<span style="color: #000066; font-weight: bold;">write</span><span style="color: #66cc66;">(</span><span style="color: #3366CC;">"<a href=<span style="color: #000099; font-weight: bold;">\"</span>javascript:self.close();<span style="color: #000099; font-weight: bold;">\"</span>>Close window</a>"</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>
window.<span style="color: #006600;">document</span>.<span style="color: #000066;">close</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
window.<span style="color: #000066;">focus</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;
<span style="color: #66cc66;">}</span>
以上是关于javascript 打开窗户的主要内容,如果未能解决你的问题,请参考以下文章