JavaScript視窗和架構

來源:互聯網
上載者:User
javascript

54 改變瀏覽器狀態列文字提示
1<script language=”JavaScript”>
2 window.status = “A new status message”;
3</script>
55 彈出確認提示框
1<script language=”JavaScript”>
2 var userChoice = window.confirm(“Click OK or Cancel”);
3 if (userChoice) {
4   document.write(“You chose OK”);
5 } else {
6   document.write(“You chose Cancel”);
7 }
8</script>
56 提示輸入
1<script language=”JavaScript”>
2 var userName = window.prompt(“Please Enter Your Name”,”Enter Your Name Here”);
3 document.write(“Your Name is “ + userName);
4</script>
57 開啟一個新視窗
1//開啟一個名稱為myNewWindow的瀏覽器新視窗
2<script language=”JavaScript”>
3  window.open(“http://www.xrss.cn”,”myNewWindow”);
4</script>
58 設定新視窗的大小
1<script language=”JavaScript”>
2 window.open(“http://www.xrss.cn”,”myNewWindow”,'height=300,width=300');
3</script>
59 設定新視窗的位置
1<script language=”JavaScript”>
2 window.open(“http://www.xrss.cn”,”myNewWindow”,'height=300,width=300,left=200,screenX=200,top=100,screenY=100');
3</script>
60 是否顯示工具列和滾動欄
1<script language=”JavaScript”>
2 window.open(http://www.xrss.cn","myNewWindow","toolbar=no,  scrollbars=no, ");
3</script>

61 是否可以縮放新視窗的大小
1<script language=”JavaScript”>
2 window.open('http://www.xrss.cn' , 'myNewWindow', 'resizable=yes' );
3</script>
62 載入一個新的文檔到當前視窗
1<a href='#' );”>Open a full-screen window</a>
65 新視窗和父視窗的操作
1<script language=”JavaScript”>
2 //定義新視窗
3 var newWindow = window.open(“128a.html”,”newWindow”);
4 newWindow.close(); //在父視窗中關閉開啟的新視窗
5</script>
6
7在新視窗中關閉父視窗
8window.opener.close()
66 往新視窗中寫內容
1<script language=”JavaScript”>
2 var newWindow = window.open(“”,”newWindow”);
3 newWindow.document.open();
4 newWindow.document.write(“This is a new window”);
5 newWIndow.document.close();
6</script>
67 載入頁面到架構頁面
1<frameset cols=”50%,*”>
2<frame name=”frame1” src="/”135a.html"”>
3<frame name=”frame2” src="/”about:blank"”>
4</frameset>
5在frame1中載入frame2中的頁面
6parent.frame2.document.location = “135b.html”;
68 在架構頁面之間共用指令碼
如果在frame1中html檔案中有個指令碼 1function doAlert() {
2 window.alert(“Frame 1 is loaded”);
3} 那麼在frame2中可以如此調用該方法
1<body onLoad=”parent.frame1.doAlert();”>
2 This is frame 2.
3</body>
4
69 資料公用
可以在架構頁面定義資料項目,使得該資料可以被多個架構中的頁面公用
1<script language=”JavaScript”>
2 var persistentVariable = “This is a persistent value”;
3</script>
4<frameset cols=”50%,*”>
5<frame name=”frame1” src="/”138a.html"”>
6<frame name=”frame2” src="/”138b.html"”>
7</frameset> 這樣在frame1和frame2中都可以使用變數persistentVariable

70 架構程式碼程式庫
根據以上的一些思路,我們可以使用一個隱藏的架構頁面來作為整個框架組的程式碼程式庫
1<frameset cols=”0,50%,*”>
2<frame name=”codeFrame” src="/”140code.html"”>
3<frame name=”frame1” src="/”140a.html"”>
4<frame name=”frame2” src="/”140b.html"”>
5</frameset> 
6



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.