首页  >  文章  >  web前端  >  js打开新窗口方法整理_javascript技巧

js打开新窗口方法整理_javascript技巧

WBOY
WBOY原创
2016-05-16 16:59:481240浏览

window.location="aaa.aspx"

上面的方法只能在当前页打开,如果要在新的页面打开,最简单的是用以下方法

form.target="_blank";
form.action="aaa.aspx";
form.submit();

window.top.location=url 可以在iframe中的页面在父窗口刷新打开

window.open方法可控制的样式丰富,比如我们可以控制窗口显示的大小,窗口显示的内容,以及位置等等。都是使用js中的window.open有一个缺点就是容易被浏览器屏蔽。本文介绍了js中打开新窗口的各种方法。

1,打开新窗口全屏

复制代码 代码如下:


blue
<SCRIPT> <br>function ow(owurl){ <br>var tmp=window.open("about:blank","","fullscreen=1") <br>tmp.moveTo(0,0); <br>tmp.resizeTo(screen.width 20,screen.height); <br>tmp.focus(); <br>tmp.location=owurl; <br>} <br></SCRIPT>



blog

2,打开新窗口固定大小
复制代码 代码如下:

open1

open3

3,默认大小开启
复制代码 代码如下:

<script> <br>//tmtC_winMaximizer <br>if (document.layers){ <br>var larg=screen.availWidth-10; <br>var altez=screen.availHeight-20;} <br>else{ <br>var larg=screen.availWidth-2; <br>var altez=screen.availHeight;} <br>self.resizeTo(larg,altez); <br>self.moveTo(0,0); <br>//tmtC_winMaximizerEnd <br></script>

--------------------------------------------





4,正常打开打开一个弹出窗口
复制代码 代码如下:


function WinOpen() {
mesg=open("cnrose","DisplayWindow","toolbar=no,,menubar=no,location=no,scrollbars=no");
mesg.document.write("中国asp之家");
mesg.document.write("
http://www.aspxhome
");
}





----------------------------------------------------------------------------------------------

a

5,Chromeless Window For IE6 SP1
复制代码 代码如下:




<标题>ChromelessWindow



var CW_width = 400;
var CW_height = 300;
var CW_top = 100;
var CW_left = 100;
var CW_url = "http://www.cnbruce.com/bluebook/";
var New_CW = window.createPopup();
var CW_Body = New_CW.document.body;
var content = "";
var CSStext = "margin:1px;color:black; border:2pxoutset;border-style:expression_r(onmouseout=onmouseup=function(){this.style.borderStyle='outset'},onmousedown=function(){ if(event.button!=2)this.style.borderStyle='inset'});背景颜色:buttonface;宽度:16px;高度:14px;字体大小:12px;行高:11px;光标:默认;”;

//构建窗口
include.startDownload(CW_url,function(source){content=source});

function insert_content(){
var temp = "";
CW_Body.style.overflow = "隐藏";
CW_Body.style.backgroundColor = "白色";
CW_Body.style.border = "纯黑1px";
content = content.replace(/]*)>/g,"");
temp = "";
temp = "";
temp = "ChromelessWindow 适用于 IE6 SP1";
temp = "";
temp = "?";
temp = "0< /跨度>";
temp = "1";
temp = "x";
temp ="";
temp = "
";
温度=内容;
temp = "
";
temp ="";
CW_Body.innerHTML = 临时;
}

setTimeout("insert_content()",1000);

var if_max = true;
函数 show_CW(){
window.moveTo(10000, 10000);
if(if_max){
New_CW.show(CW_top, CW_left, CW_width, CW_height);
if(typeof(New_CW.document.all.include)!="undefined"){
New_CW.document.all.include.style.width = CW_width;
New_CW.document.all.Max.innerText = "1";
}

}else{
New_CW.show(0, 0, screen.width, screen.height);
New_CW.document.all.include.style.width = screen.width;
}
}

window.onfocus = show_CW;
window.onresize = show_CW;

// 移动窗口
var Drag_x,drag_y,draging=false

function Drag_move(e){
if (draging){
New_CW.show(e. screenX-drag_x, e.screenY-drag_y, CW_width,CW_height);
返回错误;
}
}

函数drag_down(e){
if(e.button==2)return;
if(New_CW.document.body.offsetWidth==screen.width&&New_CW.document.body.offsetHeight==screen.height)return;
drag_x=e.clientX;
drag_y=e.clientY;
拖动=true;
e.srcElement.setCapture();
}

函数drag_up(e){
拖动=false;
e.srcElement.releaseCapture();
if(New_CW.document.body.offsetWidth==screen.width&&New_CW.document.body.offsetHeight==screen.height) return;
CW_top = e.screenX-drag_x;
CW_left = e.screenY-drag_y;
}




6,打开即全屏
复制代码代码如下:


<头>

js打开新闻方法代码收集 - 中国asp之家-http://www.aspxhome








-------------------------------------------------------- --------------------------------------------------

<脚本>
window.open('/','','全屏=1');
窗口.close();


7,网页对话框
复制代码代码如下:

;
window.onload=function(){
varfeatures='status:0;dialogWidth:470px;dialogHeight:470px;dialogTop:100px;dialogLeft:100px;ressized:0;scroll:0;center:1';
showModelessDialog("http://www.aspxhome/",窗口,功能);
}
function show(laysn)
{
var obj;
obj=laysn.style;
obj.visibility='可见';
}
隐藏函数(laysn)
{
var obj;
obj=laysn.style;
obj.visibility='隐藏';
}


8,子窗口打开,关闭父窗口
复制代码代码如下:

<脚本>
window.open('http://www.aspxhome.com/','','width=790,height=590');
window.opener=null;
窗口.close();

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn