Window.location = "aaa.aspx"
Metode di atas hanya dapat dibuka pada halaman saat ini.
form.target = "_ blank";
form.action = "aaa.aspx";
form.submit ();
Window.top.location = URL dapat dibuka di jendela induk di halaman di iframe
Metode Window.open kaya akan gaya. Ada kerugian untuk menggunakan jendela. Buka di JS yang mudah diblokir oleh browser. Artikel ini memperkenalkan berbagai metode untuk membuka jendela baru di JS.
1. Buka layar penuh jendela baru
Salin kode kode sebagai berikut:
<html> <head>
<title> biru </iteme>
<script>
Function ow (owurl) {
var tmp = window.open ("tentang: 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. Buka ukuran tetap jendela baru
Salin kode kode sebagai berikut:
<ButtonClick = "window.open ('/red/', '', 'width = 800, height = 300')"> open1 </button>
<Tombol OnClight = "varnewwin = window.open ('/merah/'); newwin.moveto (50,50); newwin.resizeto (800.300)"> Open2 </button>
<butononClight = "window.showmodelessdialog ('/red', '', 'dialogwidth: 800px; dialogHeight: 300px')"> Open3 </buttpute>
3. Buka ukuran default
Salin kode kode sebagai berikut:
<script>
// tmtc_winmaximizer
if (document.layers) {
var larg = screen.availwidth-10;
var altez = screen.availheight-20;}
kalau tidak {
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. Buka secara normal dan buka jendela pop -up
Salin kode kode sebagai berikut:
<ScriptLanguage = "JavaScript">
Fungsi winopen () {
Mesg = buka ("cnrose", "displaywindow", "toolbar = tidak, menubar = tidak, lokal = tidak, scrollbars = tidak");
mesg.document.write (<agead> <title> rumah asp Cina </itement> </head> ");
mesg.document.write ("<ter enter> http: //www.aspxhome </denter>");
}
</script>
<sorm>
<input type = "tombol" name = "button1" value = "cn-bruce" onclick = "winopen ()">
</form>
-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------
<a href =#onclick = window.open ('http: //www.aspxhome' ,'target' ,'param')> a </a>
5. Jendela Chromeless untuk IE6 SP1
Salin kode kode sebagai berikut:
<Html xmlns: IE>
<meta http-equiv = "konten tipe" content = "text/html; charset = gb2312">
<Ie: download id = "include" style = "behavior: url (#default#download)" /> />
<title> chromelessWindow </iteme>
<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 csStext = "margin: 1px; warna: hitam; border: 2pxoutset; border-style: ekspresi_r (onmouseout = onmouseup = function () {this.style.borderstyle = 'outset'}, onmousedown = function () {if (event .BUTTON! ";";
// Bangun jendela
Incert.startdownload (cw_url, fungsi (sumber) {content = sumber});
fungsi insert_content () {
var test = "" ;;
Cw_body.style.overflow = "tersembunyi";
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 += "<lebar tabel = 100% tinggi = 100% cellpadding = 0cellspacing = 0 border = 0>" ";
temp += "<trstyle = '; font-size: 12px; latar belakang:#0099cc; tinggi: 20; kursor: default'ondblClick =/" max.innertext ==' 1 '?' 2 ':': 1 '; Parent.if_max =! Kembalikan false'oncontextMenu = 'return false'> "";
Temp += "<tdstyle = 'color: #ffffff; padding-heft: 5px'> chromelessWindow untuk IE6 sp1 </td>" ";
Temp += "<tdstyle = 'color: #ffffff; padding-right: 5px;' Align = right>" ;;
Temp += "<span id = bantuan onsclick =/" alert ('chromelessWindow untuk IE6 sp1 -ver 1.0 // ncode oleh windy_sk // n // nspecialthans untuk dan "style =/" "" "" "" "" + 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 = Max OnClick =/" This.innerText = this.innerText == '1'? "Style =/"+cssttext+"font-family: webdings;/" title = 'maksimum'> 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 = includeestyle = 'overflow: gulir; overflow-x: tersembunyi; overflow-y: auto; tinggi: 100%; lebar:"+cwidth+"'" "" ";
Temp += konten;
temp += "</div>";
temp += "</td> </tr> </able>" ";
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);
ifof (new_cw.document.ling.include)!
New_cw.document.all.include.style.width = cw_width;
New_cw.document.all.max.innertext = "1";
}
} Kalau tidak {
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;
// Pindahkan jendela
var drag_x, drag_y, draging = false
fungsi drag_move (e) {
if (draging) {
New_cw.show (e.screen-drag_x, e.screeny-drag_y, cw_width, cw_height);
Mengembalikan false;
}
}
Fungsi drag_down (e) {
if (e.button == 2) kembali;
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 ();
}
fungsi drag_up (e) {
seret = false;
e.srcelement.releasecapture ();
if (new_cw.document.body.offsetWidth == screen.width && new_cw.document.offsetHeight == screen.height)
Cw_top = e.screen-drag_x;
CW_LEFT = e.screeny-drag_y;
}
</script>
</html>
6, buka layar penuh
Salin kode kode sebagai berikut:
<Html>
<head>
<meta http-equiv = "konten tipe" content = "text/html; charset = gb2312">
<title> metode js untuk membuka koleksi kode jendela baru - China ASP Home - http: //www.aspxhome </iteme>
<tautan href = "index.css" rel = "stylesheet" type = "text/css">
<bahasa skrip = "javascript" type = "text/javascript">
<!-
Fungsi machakfull (yaitu, lainnya) {
x = screen.availwidth;
y = screen.availheight;
target = 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 (lainnya, "sub", 'scrollbars = ya');
if (target> = 4) {
if (navigator.appname == "netscape") {
varmachakfull = window.open (lainnya, "machakfull", 'scrollbars = yes', 'width ='+x+', height ='+y+', atas = 0, kiri = 0');
Machakfull.moveto (0,0);
Machakfull.resizeto (x, y);}
if (navigator.appname == "Microsoft Internet Explorer")
window.open (yaitu, "machakfull", "layar penuh = ya");
}
lain window.open (lainnya, "sub", 'scrollbars = ya');
}
Fungsi mm_goTourl () {//v3.0
var i, args = mm_goTourl.arguments;
untuk (i = 0; i <(args.length-); i+= 2) eval_r (args [i]+". Lokasi = '"+args [i+1]+"'");
}
//->
</script>
</head>
<body bgcolor = "#3366cc" scroll = noonload = "machakfull ('/bbs/', '')">
-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------
<script>
Window.open ('/', '', 'fullscreen = 1');
window.close ();
</script>
7, kotak dialog web
Salin kode kode sebagai berikut:
<script>
window.onload = function () {
varfeatures = 'Status: 0; Dialogwidth: 470px; DialogHeight: 470px; Dialogtop: 100px; Dialogleft: 100px; dapat diputar ulang: 0; gulir: 0; tengah: 1';
showmodelessDialog ("http: //www.aspxhome/", window, fitur);
}
Function Show (LAASN)
{{
var obj;
obj = laysn.style;
obj.visibility = 'visible';
}
Fungsi tersembunyi (laysn)
{{
var obj;
obj = laysn.style;
obj.visibility = 'tersembunyi';
}
</script>
8. Jendela anak membuka dan menutup jendela induk
Salin kode kode sebagai berikut:
<script>
Window.open ('http://www.aspxhome.com/' ,'width=790, tinggi = 590');
Window.opner = null;
window.close ();
</script>