Home > Web Front-end > JS Tutorial > body text

js open new window method arrangement_javascript skills

WBOY
Release: 2016-05-16 16:59:48
Original
1248 people have browsed it

window.location="aaa.aspx"

The above method can only be opened on the current page. If you want to open it on a new page, the easiest way is to use the following method

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

window.top.location=url The page in the iframe can be refreshed and opened in the parent window

The window.open method can control a variety of styles. For example, we can control the size of the window display, the content of the window display, and the position, etc. One disadvantage of using window.open in js is that it is easily blocked by the browser. This article introduces various methods of opening new windows in js.

1, open a new window full screen

Copy the code The code is as follows:


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, open a new window with fixed size
Copy code The code is as follows:

open1

open3

3, the default size is enabled
Copy code The code is as follows:

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


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





4, open a pop-up window normally
Copy code The code is as follows:


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



< /form>

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

a

5, Chromeless Window For IE6 SP1
Copy code The code is as follows:




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'});background-color:buttonface;width:16px;height:14px;font-size:12px;line-height:11px;cursor:Default;";

//Build Window
include.startDownload(CW_url,function(source){content=source});

function insert_content(){
var temp = "";
CW_Body.style.overflow = "hidden";
CW_Body.style.backgroundColor = "white";
CW_Body.style.border = "solid black 1px";
content = content.replace(/]*)>/g,"");
temp = "";
temp = "";
temp = "ChromelessWindow For IE6 SP1";
temp = "";
temp = "?";
temp = "0";
temp = "1";
temp = "x";
temp ="
";
temp = "
";
temp = content;
temp = "
";
temp ="
";
CW_Body.innerHTML = temp;
}

setTimeout("insert_content()",1000);

var if_max = true;
function 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;

// Move Window
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);
return false;
}
}

function 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;
draging=true;
e.srcElement.setCapture();
}

function drag_up(e){
draging=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






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

<script> <br>window.open('/','','fullscreen=1'); <br>window.close(); <br></script>

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

<script> <br>window.onload=function(){ <br>varfeatures='status:0;dialogWidth:470px;dialogHeight:470px;dialogTop:100px;dialogLeft:100px;resizable:0;scroll:0;center:1'; <br>showModelessDialog("http://www.aspxhome/",window,features); <br>} <br>function show(laysn) <br>{ <br>var obj; <br>obj=laysn.style; <br>obj.visibility='visible'; <br>} <br>function hidden(laysn) <br>{ <br>var obj; <br>obj=laysn.style; <br>obj.visibility='hidden'; <br>} <br></script>

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

<script> <br>window.open('http://www.aspxhome.com/','','width=790,height=590'); <br>window.opener=null; <br>window.close(); <br></script>
Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template