JS入門代碼集合
更新時間:2008年05月29日 23:10:02 作者:
在閃吧看見了一篇js教程,感覺不錯 適合閱讀范圍:對JavaScript一無所知~離精通只差一步之遙的人
61 是否可以縮放新窗口的大小
1: <script language=”JavaScript”>
2: window.open('http://www.liu21st.com/' , 'myNewWindow', 'resizable=yes' );</script>
62 加載一個新的文檔到當前窗口
1: <a href='#' onClick='document.location = '125a.html';' >Open New Document</a>
63 設置頁面的滾動位置
1: <script language=”JavaScript”>
2: if (document.all) { //如果是IE瀏覽器則使用scrollTop屬性
3: document.body.scrollTop = 200;
4: } else { //如果是NetScape瀏覽器則使用pageYOffset屬性
5: window.pageYOffset = 200;
6: }</script>
64 在IE中打開全屏窗口
1: <a href='#' onClick=”window.open('http://www.juxta.com/','newWindow','fullScreen=yes');”>Open a full-screen window</a>
65 新窗口和父窗口的操作
1: <script language=”JavaScript”>
2: //定義新窗口
3: var newWindow = window.open(“128a.html”,”newWindow”);
4: newWindow.close(); //在父窗口中關(guān)閉打開的新窗口
5: </script>
6: 在新窗口中關(guān)閉父窗口
7: window.opener.close()
66 往新窗口中寫內(nèi)容
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中的頁面
6: parent.frame2.document.location = “135b.html”;
68 在框架頁面之間共享腳本
如果在frame1中html文件中有個腳本
1: function doAlert() {
2: window.alert(“Frame 1 is loaded”);
3: }
那么在frame2中可以如此調(diào)用該方法
1: <body onLoad=”parent.frame1.doAlert();”>
2: This is frame 2.
3: </body>
69 數(shù)據(jù)公用
可以在框架頁面定義數(shù)據(jù)項,使得該數(shù)據(jù)可以被多個框架中的頁面公用
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 框架代碼庫
根據(jù)以上的一些思路,我們可以使用一個隱藏的框架頁面來作為整個框架集的代碼庫
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>
相關(guān)文章
詳解在網(wǎng)頁上通過JS實現(xiàn)文本的語音朗讀
這篇文章主要介紹了在網(wǎng)頁上通過JS實現(xiàn)文本的語音朗讀,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-03-03
js onkeypress與onkeydown 事件區(qū)別詳細說明
本文將詳細介紹js onkeypress與onkeydown 事件區(qū)別:一個放開一個沒有放開,onkeydown先于onkeypress 發(fā)生,需要的朋友可以參考下2012-12-12
javascript下for循環(huán)用法小結(jié)
javascript下for循環(huán)用法小結(jié)...2007-07-07
JavaScript中的Math.SQRT1_2屬性使用簡介
這篇文章主要介紹了JavaScript中的Math.SQRT1_2屬性的使用,是JS入門學習中的基礎(chǔ)知識,需要的朋友可以參考下2015-06-06
javascript 數(shù)組的定義和數(shù)組的長度
本文主要介紹javascript 數(shù)組的定義和數(shù)組的長度,比較簡單,希望能給大家做一個參考。2016-06-06
用Object.prototype.toString.call(obj)檢測對象類型原因分析
在本篇文章里我們給大家剖析了用Object.prototype.toString.call(obj)檢測對象類型的原因,需要的朋友們可以學習下。2018-10-10

