Window. location = "aaa. aspx"
The preceding method can only be opened on the current page. to open a new page, use the following method
Form.tar get = "_ blank ";
Form. action = "aaa. aspx ";
Form. submit ();
Window. top. location = url can be refreshed in the parent window on the page in iframe.
The window. open method has a variety of controllable styles, such as the size, content, and position of the window display. Windows. open in js has a disadvantage that it is easily blocked by browsers. This article describes how to open a new window in js.
1. Open new window full screen
Copy codeThe Code is as follows:
<Html> <Title> blue </title>
<SCRIPT>
Function ow (owurl ){
Var tmp = window. open ("about: blank", "", "fullscreen = 1 ")
Tmp. moveTo (0, 0 );
Tmp. resizeTo (screen. width + 20, screen. height );
Tmp. focus ();
Tmp. location = owurl;
}
</SCRIPT>
</Head>
<Body>
<Ahref = "javascript: ow ('HTTP: // www.aspxhome.com/');">
Blog </a>
2. open a new window with a fixed size
Copy codeThe Code is as follows:
<Buttononclick = "window. open ('/red/','', 'width = 800, height = 300 ') "> open1 </button>
<Button onclick = "varnewwin = window. open ('/red/'); newwin. moveTo (50,50); newwin. resizeTo (800,300)"> open2 </button>
<Buttononclick = "window. showModelessDialog ('/red','', 'dialogwidth: 800px; dialogHeight: 300px') "> open3 </button>
3. The default size is enabled.
Copy codeThe Code is as follows:
<Script>
// 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
</Script>
--------------------------------------------
<Scriptlanguage = "JavaScript">
<! --
Self. moveTo (0, 0)
Self. resizeTo (screen. availWidth, screen. availHeight)
// -->
</Script>
4. normally open a pop-up window
Copy codeThe Code is as follows:
<Scriptlanguage = "JavaScript">
Function WinOpen (){
Mesg = open ("cnrose", "DisplayWindow", "toolbar = no, menubar = no, location = no, scrollbars = no ");
Mesg.doc ument. write ("<HEAD> <TITLE> Chinese asp house </TITLE> </HEAD> ");
Mesg.doc ument. write ("<CENTER> http://www.aspxhome </CENTER> ");
}
</Script>
<Form>
<Input type = "button" name = "Button1" value = "CN-Bruce" onclick = "WinOpen ()">
</Form>
Bytes ----------------------------------------------------------------------------------------------
<A href = # onclick = window. open ('HTTP: // www. aspxhome ', 'target', 'param')> a </a>
5, Chromeless Window For IE6 SP1
Copy codeThe Code is as follows:
<Html xmlns: IE>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<IE: Download ID = "include" STYLE = "behavior: url (# default # download)"/>
<Title> ChromelessWindow </title>
<SCRIPTLANGUAGE = "JScript">
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_c0000document.body;
Var content = "";
Var CSStext = "margin: 1px; color: black; border: 2 pxoutset; 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 (/<a ([^>] *)>/g, "<aonclick = 'parent. open (this. href); return false '$1> ");
Temp + = "<table width = 100% height = 100% cellpadding = 0 cellspacing = 0 border = 0> ";
Temp + = "<trstyle = '; font-size: 12px; background: # 0099CC; height: 20; cursor: default 'ondblclick = \" Max. innerText = Max. innerText = '1 '? '2': '1'; parent. if_max =! Parent. if_max; parent. show_CW (); \ "onmouseup = 'parent. drag_up (event) 'onmousemove = 'parent. drag_move (event) 'onmousedown = 'parent. drag_down (event) 'onselectstart = 'Return false' oncontextmenu = 'Return false'> ";
Temp + = "<tdstyle = 'color: # ffffff; padding-left: 5px '> ChromelessWindow For IE6 SP1 </td> ";
Temp + = "<tdstyle = 'color: # ffffff; padding-right: 5px; 'align = right> ";
Temp + = "<span id = Help onclick = \" alert ('chromelesswindow For IE6 SP1-Ver 1.0 \ n \ nCode By Windy_sk \ n \ nSpecialThanks For andot') \ "style = \" "+ CSStext +" font-family: System; padding-right: 2px; \ ">? </Span> ";
Temp + = "<spanid = Min onclick = 'parent. new_c1_hide (); parent. blur () 'style = \ "" + CSStext + "font-family: Webdings; \" title = 'minimum '> 0 </span> ";
Temp + = "<spanid = Max onclick = \" this. innerText = this. innerText = '1 '? '2': '1'; parent. if_max =! Parent. if_max; parent. show_CW (); \ "style = \" "+ CSStext +" font-family: Webdings; \ "title = 'maximum '> 1 </span> ";
Temp + = "<span id = Closeonclick = 'parent. opener = null; parent. close () 'style = \ "" + CSStext + "font-family: System; padding-right: 2px; \" title = 'close'> x </span> ";
Temp + = "</td> </tr> <tdcolspan = 2> ";
Temp + = "<div id = includestyle = 'overflow: scroll; overflow-x: hidden; overflow-y: auto; HEIGHT: 100%; width: "+ CW_width +" '> ";
Temp + = content;
Temp + = "</div> ";
Temp + = "</td> </tr> </table> ";
CW_Body.innerHTML = temp;
}
SetTimeout ("insert_content ()", 1000 );
Var if_max = true;
Function show_CW (){
Window. moveTo (10000,100 00 );
If (if_max ){
New_c1_show (CW_top, CW_left, CW_width, CW_height );
If(typeof(new_c0000doc ument. all. include )! = "Undefined "){
New_c0000document.all.include.style.width = CW_width;
New_c1_document.all.max.innertext = "1 ";
}
} Else {
New_c1_show (0, 0, screen. width, screen. height );
New_c0000document.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_c0000document.body.offsetwidth?#screen.width&new_c=doc ument. 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_c0000document.body.offsetwidth?#screen.width&new_c=doc ument. body. offsetHeight = screen. height) return;
CW_top = e. screenX-drag_x;
CW_left = e. screenY-drag_y;
}
</SCRIPT>
</HTML>
6. enable full screen
Copy codeThe Code is as follows:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> js open new window method code collection-China asp house-http://www.aspxhome </title>
<Link href = "index.css" rel = "stylesheet" type = "text/css">
<Script language = "JavaScript" type = "text/JavaScript">
<! --
Function MachakFull (Ie, other ){
X = screen. availWidth;
Y = screen. availHeight;
Target = parseFloat (navigator. appVersion. substring (navigator. appVersion. indexOf ('.')-1, navigator. appVersion. length ));
If (navigator. appVersion. indexOf ("Mac ")! =-1) & (navigator. userAgent. indexOf ("MSIE ")! =-1) & (parseInt (navigator. appVersion) = 4 ))
Window. open (other, "sub", 'rollbars = yes ');
If (target> = 4 ){
If (navigator. appName = "Netscape "){
VarMachakFull = window. open (other, "MachakFull", 'rollbars = yes', 'width = '+ x +', height = '+ y +', top = 0, left = 0 ');
MachakFull. moveTo (0, 0 );
MachakFull. resizeTo (x, y );}
If (navigator. appName = "Microsoft Internet Explorer ")
Window. open (Ie, "MachakFull", "fullscreen = yes ");
}
Else window. open (other, "sub", 'rollbars = yes ');
}
Function MM_goToURL () {// v3.0
Var I, args = MM_goToURL.arguments; document. MM_returnValue = false;
For (I = 0; I <(args. length-1); I + = 2) eval_r (args [I] + ". location = '"+ args [I + 1] + "'");
}
// -->
</Script>
</Head>
<Body bgcolor = "# 3366CC" SCROLL = NOonload = "MachakFull ('/bbs/','') ">
Bytes ----------------------------------------------------------------------------------------------
<Script>
Window. open ('/', '', 'fullscreen = 1 ');
Window. close ();
</Script>
7. webpage dialog box
Copy codeThe Code is as follows:
<Script>
Window. onload = function (){
Varfeatures = 'status: 0; dialogWidth: 470px; dialogHeight: 470px; dialogTop: 100px; dialogLeft: 100px; resizable: 0; scroll: 0; center: 1 ';
ShowModelessDialog ("http://www.aspxhome/", window, features );
}
Function show (laysn)
{
Var obj;
Obj = laysn. style;
Obj. visibility = 'visable ';
}
Function hidden (laysn)
{
Var obj;
Obj = laysn. style;
Obj. visibility = 'ddn ';
}
</Script>
8. The child window is opened and the parent window is closed.
Copy codeThe Code is as follows:
<Script>
Window. open ('HTTP: // www.aspxhome.com/', '', 'width%790,height%590 ');
Window. opener = null;
Window. close ();
</Script>