瀏覽器javascript學習筆記

來源:互聯網
上載者:User
Code
// JavaScript Document
//瀏覽器視窗在當前位置移動 水平x 像素  垂直y像素
window.moveBy(x,y);
//行動瀏覽器 視窗  使其左上方位於螢幕(x,y)處
widows.moveTo(x,y);   
//調整browser大小
resizeTo(x,y);

//調整browser當前大小   正數為增加  負數為減小
resizeBy(x,y);

window.open("www.eping.net", "eping");
//window.open("URL", "name","features",boolean replace);
//features 參數   int型   left top height width  
//                bool值   esizeable(改變大小) scrollable  toolbar  location(顯示地址)

//系統對話方塊

widows.alert("message");
//確認對話方塊
window.confirm("message");
//confirm有傳回值

//當需要使用者輸入資料再確認時
 var result = widows.prompt("this is prompt ", "default value");   //這個結果是可以返回的

//狀態列使用

window.status = "infomation";  //設定狀態列資訊
widows.defaultStatus = "default infomation" ;//  設定狀態列預設資訊

//時間間隔和暫停

var timeoutID = window.setTimeout(code,msNum);
//code  固定時間執行的代碼  相當於VC中的SetTimer      msNum毫秒   
window.clearTimeout(timeoutID);

//還可以調用
function testInterval()
{
    //接收window.setInterval 返回的數字暫停ID
    intervalID=window.setInterval("alert(\"今天學習時間間隔\")",1000);
}
widows.clearInterval(intervalID);

//曆吏記錄
window.history.go(-1);  //負數為後退   正數為前進
widows.history.back();  //回退至前面在history中所處位置的一項曆吏記錄
window.history.forward(); //

//screen  對象     
//window.screen   使用者訪問使用者的螢幕資訊    

/*
availHeight   視窗可以使用的螢幕高度    以像素為基本單位
avaliWidth    同上

colorDepth     使用者螢幕顏色的位元    
height
width   

*/

//location 對象
//表示載入視窗的URL   同時是window性性也是document屬性
//window.location.hash()   如果該URL包含#  該方法返回 該符號後面的內容   eg:http://www.eping.net/index.html#eping    調用hash
//方法返回#eping
//host   伺服器名  eg:http://www.eping.net/index    host 值為www.eping.net
//href   當前頁面完整URL
//pathname   服務名後面的部分  eg:http://www.eping.net/index   面後部分為  index
//protocol   表單URL所使用的通訊協定
//search     表單URL中查詢記字串eg:http://www.eping.net/index?username=eping search的屬性值為 ?username=eping
//reload     重新載入頁面   false  從緩衝載入頁面   true 從伺服器端載入頁面
//assign     有一個字串參數    該方法設定當前頁面location.href 為該參數
//replace()   有一個字串參數    該方法先設定當前頁面location.href 為該參數  然後從browser 記錄刪除當前頁面

//頁面跳轉

window.location.href = "www.eping.net" ;
widows.location.assign("http://www.eping.net");

window.location.reload("http://www.eping.net"); //不能後退至本頁   會自動刪除記錄

//重新載入頁面  
window.location.reload();
window.location.reload(false);
//上面兩種效果是一樣的

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.