- 論壇徽章:
- 0
|
54 改變?yōu)g覽器狀態(tài)欄文字提示
script language=”JavaScript”>
window.status = “A new status message”;
55 彈出確認(rèn)提示框
script language=”JavaScript”>
var userChoice = window.confirm(“Click OK or Cancel”);
if (userChoice) {
document.write(“You chose OK”);
} else {
document.write(“You chose Cancel”);
}
56 提示輸入
script language=”JavaScript”>
var userName = window.prompt(“Please Enter Your Name”,”Enter Your Name Here”);
document.write(“Your Name is “ + userName);
57 打開一個新窗口
//打開一個名稱為myNewWindow的瀏覽器新窗口
script language=”JavaScript”>
window.open(“http://www.liu21st.com/”,”myNewWindow”);
58 設(shè)置新窗口的大小
script language=”JavaScript”>
window.open(“http://www.liu21st.com/”,”myNewWindow”,'height=300,width=300');
59 設(shè)置新窗口的位置
script language=”JavaScript”>
window.open(“http://www.liu21st.com/”,”myNewWindow”,'height=300,width=300,left=200,screenX=200,top=100,screenY=100');
60 是否顯示工具欄和滾動欄
script language=”JavaScript”>
window.open(“http:
61 是否可以縮放新窗口的大小
script language=”JavaScript”>
window.open('http://www.liu21st.com/' , 'myNewWindow', 'resizable=yes' );
62 加載一個新的文檔到當(dāng)前窗口
a href='#' onClick='document.location = '125a.html';' >Open New Documenta>
63 設(shè)置頁面的滾動位置
script language=”JavaScript”>
if (document.all) { //如果是IE瀏覽器則使用scrollTop屬性
document.body.scrollTop = 200;
} else { //如果是NetScape瀏覽器則使用pageYOffset屬性
window.pageYOffset = 200;
}
64 在IE中打開全屏窗口
a href='#' onClick=”window.open('http://www.juxta.com/','newWindow','fullScreen=yes');”>Open a full-screen windowa>
65 新窗口和父窗口的操作
script language=”JavaScript”>
//定義新窗口
var newWindow = window.open(“128a.html”,”newWindow”);
newWindow.close(); //在父窗口中關(guān)閉打開的新窗口
在新窗口中關(guān)閉父窗口
window.opener.close()
66 往新窗口中寫內(nèi)容
script language=”JavaScript”>
var newWindow = window.open(“”,”newWindow”);
newWindow.document.open();
newWindow.document.write(“This is a new window”);
newWIndow.document.close();
67 加載頁面到框架頁面
frameset cols=”50%,*”>
frame name=”frame1” src=”135a.html”>
frame name=”frame2” src=”about:blank”>
frameset>
在frame1中加載frame2中的頁面
parent.frame2.document.location = “135b.html”;
68 在框架頁面之間共享腳本
如果在frame1中html文件中有個腳本
function doAlert() {
window.alert(“Frame 1 is loaded”);
}
那么在frame2中可以如此調(diào)用該方法
body onLoad=”parent.frame1.doAlert();”>
This is frame 2.
body>
69 數(shù)據(jù)公用
可以在框架頁面定義數(shù)據(jù)項,使得該數(shù)據(jù)可以被多個框架中的頁面公用
script language=”JavaScript”>
var persistentVariable = “This is a persistent value”;
這樣在frame1和frame2中都可以使用變量persistentVariable
70 框架代碼庫
根據(jù)以上的一些思路,我們可以使用一個隱藏的框架頁面來作為整個框架集的代碼庫
frameset cols=”0,50%,*”>
frame name=”codeFrame” src=”140code.html”>
frame name=”frame1” src=”140a.html”>
frame name=”frame2” src=”140b.html”>
frameset>
本文來自ChinaUnix博客,如果查看原文請點(diǎn):http://blog.chinaunix.net/u/15511/showart_97515.html |
|