window.location = "aaa.aspx"
วิธีการข้างต้นสามารถเปิดได้ในหน้าปัจจุบันเท่านั้น
form.target = "_ blank";
form.action = "aaa.aspx";
Form.submit ();
window.top.location = url สามารถเปิดได้ในหน้าต่างหลักบนหน้าเว็บใน iframe
วิธีการเปิดหน้าต่างมีสไตล์ที่หลากหลาย มีข้อเสียในการใช้หน้าต่างเปิดใน JS ว่าเบราว์เซอร์ถูกบล็อกได้ง่าย บทความนี้แนะนำวิธีการต่าง ๆ ในการเปิดหน้าต่างใหม่ใน JS
1. เปิดหน้าจอเต็มรูปแบบของหน้าต่างใหม่
คัดลอกรหัสรหัสดังนี้:
<html> <head>
<title> สีน้ำเงิน </title>
<script>
ฟังก์ชั่น OW (OWURL) {
var tmp = window.open ("เกี่ยวกับ: 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, ความสูง = 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 </pution>
3. เปิดขนาดเริ่มต้น
คัดลอกรหัสรหัสดังนี้:
<script>
// 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 = ไม่, local = no, scrollbars = no no");
mesg.document.write (<gead> <title> บ้าน asp จีน </title> </head> ");
mesg.document.write ("<Enter> http: //www.aspxhome </enter>");
-
</script>
<form>
<input type = "button" name = "button1" value = "cn-bruce" onclick = "winopen ()">
</form>
----------------------------------------------- ------------------------------------------------------ ------------------------------------------------------ -----------------------------------------
<a href =#onclick = window.Open ('http: //www.aspxhome' ,'target',' param ')> a </a>
5. หน้าต่างไม่มีโครเมี่ยมสำหรับ IE6 SP1
คัดลอกรหัสรหัสดังนี้:
<html xmlns: เช่น>
<meta http-equiv = "content-type" content = "text/html; charset = gb2312">>
<IE: ดาวน์โหลด id = "include" style = "พฤติกรรม: url (#default#ดาวน์โหลด)" /> />
<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 csstext = "มาร์จิ้น: 1px; สี: สีดำ; เส้นขอบ: 2pxoutset; สไตล์เส้นขอบ: expression_r (onmouseout = onMouseUp = function () {this.style.borderstyle = 'outset'}, onmousedown = function () {ถ้า ( . BUTTON! ";";
// สร้างหน้าต่าง
รวม. startdownload (cw_url, ฟังก์ชั่น (แหล่งที่มา) {content = source});
ฟังก์ชั่น insert_content () {
test var = "" ;;
cw_body.style.overflow = "ซ่อน";
cw_body.style.backgroundColor = "White";
cw_body.style.border = "Solid Black 1px";
content = content.retlace (/<a ([^>]*)>/g, "<aonclick = 'parent.open (this.href); ส่งคืน false' $ 1>");
temp += "<ความกว้างของตาราง = ความสูง 100% = 100% cellpadding = 0cellspacing = 0 border = 0>" ";
temp += "<trstyle = '; font-size: 12px; พื้นหลัง:#0099cc; ความสูง: 20; เคอร์เซอร์: default'ondblclick =/" max.innertext ==' 1 '?' 2 ':': 1 '; parent.if_max =! ส่งคืน false'onContextMenu = 'return false'> "";
temp += "<tdstyle = 'color: #ffffff; padding-heft: 5px'> ChromelessWindow สำหรับ IE6 SP1 </td>" ";
temp += "<tdstyle = 'color: #ffffff; padding-right: 5px;' Align = Right>" ;;
temp += "<span id = help onclick =/" การแจ้งเตือน ('ChromelessWindow สำหรับ IE6 SP1 -VER 1.0 // ncode โดย windy_sk // n // nspecialthans สำหรับและ "style =" "" "" "" "" CSSTTEXT+ "FONT-FAMILY: System; Padding-Right: 2px;/">? </span>;
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 = 'maximum'> 1 </span> "";
temp+= "<span id = closeOnclick = 'parent.opner = null; parent.close ()' style =/"+csstText+"Font-Family: System; Padding-Right: 2px;/" "title = 'clos'> x </span> "" ";
temp += "</td> </tr> <tr> <tdColspan = 2>" ";
temp+= "<div id = includestyle = 'overflow: scroll; overflow-x: hidden; overflow-y: auto; ความสูง: 100%; ความกว้าง:"+cwidth+"" "" "";
อุณหภูมิ += เนื้อหา;
temp += "</div>";
temp += "</td> </tr> </table>" ";
cw_body.innerhtml = temp;
-
settimeout ("insert_content ()", 1,000);
var if_max = true;
ฟังก์ชั่น show_cw () {
window.moveto (10,000, 10,000);
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";
-
} อื่น {
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);
กลับมาเป็นเท็จ;
-
-
ฟังก์ชั่น drag_down (e) {
ถ้า (e.button == 2) กลับ;
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.Srelement.setCapture ();
-
ฟังก์ชั่น drag_up (e) {
ลาก = เท็จ;
E.Srelement.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 เปิดหน้าจอเต็มรูปแบบ
คัดลอกรหัสรหัสดังนี้:
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = gb2312">>
<title> เมธอด JS เพื่อเปิดคอลเลกชันรหัสหน้าต่างใหม่ - จีน ASP Home - http: //www.aspxhome </title>
<link href = "index.css" rel = "stylesheet" type = "text/css">
<script language = "javascript" type = "text/javascript">
-
ฟังก์ชั่น Machakfull (เช่นอื่น ๆ ) {
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 (อื่น ๆ , "sub", 'scrollbars = ใช่');
if (target> = 4) {
if (navigator.appname == "netscape") {
varmachakfull = window.open (อื่น ๆ , "machakfull", 'scrollbars = ใช่', 'width ='+x+', ความสูง ='+y+', top = 0, ซ้าย = 0');
Machakfull.moveto (0,0);
machakfull.resizeto (x, y);}
if (navigator.appname == "Microsoft Internet Explorer"))
window.open (เช่น "Machakfull", "Fullscreen = ใช่");
-
else window.open (อื่น ๆ , "sub", 'scrollbars = ใช่');
-
ฟังก์ชั่น mm_gotourl () {//v3.0
var i, args = mm_gotourl.arguments;
สำหรับ (i = 0; i <(args.length-); i+= 2) eval_r (args [i]+". location = '"+args [i+1]+"" ");
-
-
</script>
</head>
<body bgcolor = "#3366cc" scroll = noonload = "machakfull ('/bbs/', '')">
----------------------------------------------- ------------------------------------------------------ ------------------------------------------------------ -----------------------------------------
<script>
window.open ('/', '', 'Fullscreen = 1');
window.close ();
</script>
7 กล่องโต้ตอบเว็บ
คัดลอกรหัสรหัสดังนี้:
<script>
window.onload = function () {
varfeatures = 'สถานะ: 0; dialogwidth: 470px; dialogheight: 470px; dialogtop: 100px; dialogleft: 100px; resizable: 0; scroll: 0; center: 1';
showModelessDialog ("http: //www.aspxhome/", หน้าต่าง, คุณสมบัติ);
-
ฟังก์ชั่นแสดง (LAASN)
-
var obj;
obj = laysn.style;
obj.visibility = 'มองเห็นได้';
-
ฟังก์ชั่นซ่อน (laysn)
-
var obj;
obj = laysn.style;
obj.visibility = 'ซ่อน';
-
</script>
8. หน้าต่างเด็กเปิดและปิดหน้าต่างหลัก
คัดลอกรหัสรหัสดังนี้:
<script>
window.open ('http://www.aspxhome.com/' ,'width=790, ความสูง = 590');
window.opner = null;
window.close ();
</script>