window.location = "aaa.aspx"
上記の方法は、現在のページでのみ開くことができます。最も簡単なのは、次の方法を使用することです。
form.target = "_ blank";
form.action = "aaa.aspx";
form.submit();
window.top.location = urlは、親のウィンドウで更新して開くことができます。
window.openメソッドはスタイルが豊富です。たとえば、ウィンドウで表示されるサイズ、窓に表示されるコンテンツなどを制御できます。 window.openを使用するには不利な点があります。ブラウザによってブロックされるのは簡単です。この記事では、JSで新しいウィンドウを開くためのさまざまな方法を紹介します。
1.新しいウィンドウの全画面を開きます
次のようにコードコードをコピーします。
<html> <head>
<title> blue </title>
<スクリプト>
関数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/');">
ブログ</a>
2.新しいウィンドウの固定サイズを開きます
次のようにコードコードをコピーします。
<buttonclick = "window.open( '/red/'、 ''、 'width = 800、height = 300')"> open1 </button>
<button onclight = "varnewwin = window.open( '/red/'); newwin.moveto(50,50); newwin.resizeto(800,300)"> open2 </button>
<butononclight = "window.showmodelessdialog( '/red'、 '' '、' dialogwidth:800px; dialogheight:300px ')"> open3 </button>
3.デフォルトのサイズを開きます
次のようにコードコードをコピーします。
<スクリプト>
// tmtc_winmaximizer
if(document.layers){
var larg = screen.availwidth-10;
var altez = screen.availheight-20;}
それ以外 {
var larg = screen.availwidth-2;
var altez = screen.availheight;}
self.resizeto(larg、altez);
self.moveto(0,0);
// TMTC_WINMAXIMANEREND
</script>
-------------------------------------------------------------- -------------------------------------------------------------- -------------------------------------------------------------- -
<ScriptLanguage = "JavaScript">
<! -
self.moveto(0,0)
self.resizeto(screen.availwidth、screen.availheight)
//->
</script>
4.正常に開き、ポップアップウィンドウを開きます
次のようにコードコードをコピーします。
<ScriptLanguage = "JavaScript">
関数winopen(){
mesg = open( "cnrose"、 "displaywindow"、 "toolbar = no、menubar = no、local = no、scrollbars = no");
mesg.document.write(<gead> <title>中国のasp house </title> </head> ");
mesg.document.write( "<inter> http://www.aspxhome </center>");
}
</script>
<form>
<入力型= "button" name = "button1" value = "cn-bruce" onclick = "winopen()">
</form>
-------------------------------------------------------------- -------------------------------------------------------------- -------------------------------------------------------------- ------------------------------------------------------------
<a href =#onclick = window.open( 'http://www.aspxhome'、 'ターゲット'、 'param')> a </a>
5。IE6SP1のクロムレスウィンドウ
次のようにコードコードをコピーします。
<html xmlns:ie>
<メタhttp-equiv = "content-type" content = "text/html; charset = gb2312">
<ie:download id = "include" style = "befivis: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_cw.document.body;
var content = "";
var cssttext = "margin:1px; color:black; border:2pxoutset; borderスタイル:expression_r(onmouseout = onmouseup = function(){this.style.borderstele = 'outset'}、onmousedown = function(){if(event(event Button! ";";
//ウィンドウを作成します
include.startdownload(cw_url、function(source){content = source});
関数INSERT_CONTENT(){
var test = "" ;;
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 = 0cellspacing = 0 border = 0>" ";
temp += "<trstyle = '; font-size:12px; background:#0099cc; height:20; cursor:default'ondblclick =/" max.innertext ==' 1 '?': ':1'; parent.if_max = false'oncontextmenu = 'return false'> "";
temp += "<tdstyle = 'color:#ffffff; padding-heft:5px'> ie6 sp1 </td>" ";
temp += "<tdstyle = 'color:#ffffff; padding-right:5px;'
temp += "<span id = help onclick =/" alert( 'chromelesswindow for ie6 sp1 -ver 1.0 // ncode bywindy_sk // n // nspecialthans for and "" "" "" "" "" "" + cssttext+ "font-family:system; padding-right:2px;/">?
temp+= "<spanid = min = 'parent.new_cw.hide(); parent.blur()' style =/"+cstetext+"font-family:webdings;/" title = 'minimum'> 0 </span> " ;
temp += "spanid = onclick =/" innertext == '1': '1'? "style =/"+cssttext+"font-family:webdings;/" title = 'maximum'> 1 </span> "";
temp+= "<span id = closeonclick = 'parent.opner = null; parent.close()' style =/"+cssttext+"font-family:system; padding-right:2px;/" "title = 'close'> x </span> "" ";
temp += "</td> </tr> <tr> <tdcolspan = 2>" ";
temp+= "<div id = includestyle = 'overflow:scroll; overflow-x:hidden; anoverflow-y:auto; height:100%; width:"+cwidth+"'" "";
temp += content;
temp += "</div>";
temp += "</td> </tr> </table>" ";
cw_body.innerhtml = temp;
}
setimeout( "insert_content()"、1000);
var if_max = true;
関数show_cw(){
window.moveto(10000、10000);
if_max){
new_cw.show(cw_top、cw_left、cw_width、cw_height);
ifof(new_cw.document.ling.include)!
new_cw.document.all.include.style.width = cw_width;
new_cw.document.all.max.innertext = "1";
}
} それ以外 {
new_cw.show(0、0、screen.width、screen.head);
new_cw.document.all.include.style.width = screen.width;
}
}
window.onfocus = show_cw;
window.onresize = show_cw;
//ウィンドウを移動します
var drag_x、drag_y、draging = false
関数drag_move(e){
if(draging){
new_cw.show(e.screen-drag_x、e.screeny-drag_y、cw_width、cw_height);
falseを返します。
}
}
関数drag_down(e){
if(e.button == 2)return;
if(new_cw.document.body.offsetwidth == screen.width && new_cw.document.offseeth == screen.height)
drag_x = e.clientx;
drag_y = e.clienty;
draging = true;
E.SRCELEMENT.SETCAPTURE();
}
関数drag_up(e){
draging = false;
E.SRCELEMENT.RELEASECAPTURE();
if(new_cw.document.body.offsetwidth == screen.width && new_cw.document.offseeth == screen.height)
cw_top = e.screen-drag_x;
cw_left = e.screeny-drag_y;
}
</script>
</html>
6、フル画面を開きます
次のようにコードコードをコピーします。
<html>
<head>
<メタhttp-equiv = "content-type" content = "text/html; charset = gb2312">
<Title> JS新しいウィンドウコードコレクションを開くメソッド-China ASP Home -http://www.aspxhome </title>
<link href = "index.css" rel = "styleSheet" type = "text/css">
<スクリプト言語= "javascript" type = "text/javascript">
<! -
function machakfull(すなわち、その他){
x = screen.availwidth;
y = screen.availheight;
ターゲット= parseflot(navigator.appversion.substring(navigator.appversion.indexof( ')-1、navigator.length););););););
if((navigator.appversion.indexof( "mac")!= -1)&&(navigator.userages.indexof( "msie")!= -1)&&(parseint(navigator.appversion)))
window.open(その他、 "sub"、 'scrollbars = yes');
if(ターゲット> = 4){
if(if(navigator.appname == "netscape"){{
varmachakfull = window.open(その他、 "machakfull"、 'scrollbars = 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(すなわち、 "machakfull"、 "fullscreen = yes");
}
else window.open(その他、 "sub"、 'scrollbars = yes');
}
関数mm_gotourl(){//v3.0
var i、args = mm_gotourl.arguments.mm_returnvalue = false;
for(i = 0; i <(args.length-); i+= 2)eval_r(args [i]+"。location = '"+args [i+1]+"'");
}
//->
</script>
</head>
<body bgcolor = "#3366cc" scroll = noonload = "machakfull( '/bbs/'、 '')">
-------------------------------------------------------------- -------------------------------------------------------------- -------------------------------------------------------------- ------------------------------------------------------------
<スクリプト>
window.open( '/'、 ''、 'fullscreen = 1');
window.close();
</script>
7、Webダイアログボックス
次のようにコードコードをコピーします。
<スクリプト>
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、feature);
}
機能ショー(ラスーン)
{{
var obj;
obj = laysn.style;
obj.visibility = 'visible';
}
function hidden(laysn)
{{
var obj;
obj = laysn.style;
obj.visibility = 'hidden';
}
</script>
8。子のウィンドウが親ウィンドウを開いて閉じます
次のようにコードコードをコピーします。
<スクリプト>
window.open( 'http://www.aspxhome.com/','width=790、height = 590');
window.opner = null;
window.close();
</script>