• 屏幕對(duì)象:

    描述屏幕的顯示及顏色屬性。

  • 屏幕對(duì)象的屬性:

    格式: screen.屬性
availHeight 屏幕區(qū)域的可用高度
availWidth 屏幕區(qū)域的可用寬度
colorDepth 顏色深度 256/8 16/16 32M/32
height 屏幕區(qū)域的實(shí)際高度
width 屏幕區(qū)域的實(shí)際寬度

例1:
<Script>

with (document) {
     write ("您的屏幕顯示設(shè)定值如下:<P>");
     write ("屏幕的實(shí)際高度為", screen.availHeight, "<BR>");
     write ("屏幕的實(shí)際寬度為", screen.availWidth, "<BR>");
     write ("屏幕的色盤深度為", screen.colorDepth, "<BR>");
     write ("屏幕區(qū)域的高度為", screen.height, "<BR>");
     write ("屏幕區(qū)域的寬度為", screen.width);
}

</Script>

例2:
<Script>

if ( screen.width < 800 || screen.colorDepth < 8 ){
     var msg = "本網(wǎng)站最佳瀏覽模式為 800 * 600 * 256";
     alert(msg);
}

</Script>

 
  • 事件對(duì)象:

    當(dāng)事件發(fā)生時(shí),瀏覽器自動(dòng)建立該對(duì)象,并包含該事件的類型、鼠標(biāo)坐標(biāo)等。
  • 事件對(duì)象的屬性:

    格式:event.屬性
data 返回拖拽對(duì)象的URL字符串(dragDrop)
width 該窗口或框架的高度
height 該窗口或框架的高度
pageX 光標(biāo)相對(duì)于該網(wǎng)頁(yè)的水平位置
pageY 光標(biāo)相對(duì)于該網(wǎng)頁(yè)的垂直位置
screenX 光標(biāo)相對(duì)于該屏幕的水平位置
screenY 光標(biāo)相對(duì)于該屏幕的垂直位置
target 該事件被傳送到的對(duì)象
type 事件的類型
which 數(shù)值表示的鍵盤或鼠標(biāo)鍵:1/2/3(左鍵/中鍵/右鍵)
layerX 光標(biāo)相對(duì)于事件發(fā)生層的水平位置
layerY 光標(biāo)相對(duì)于事件發(fā)生層的垂直位置
x 相當(dāng)于layerX
y 相當(dāng)于layerY

例1:
<Script>

function getEvent(evnt) {
eventWin = open ('','','width=200,height=100');
with (eventWin.document) {
      write("事件類型:", event.type);
      write("<br>鼠標(biāo)的x坐標(biāo):", event.screenX);
      write("<br>鼠標(biāo)的y坐標(biāo):", event.screenY);
}
}

document.write ("單擊...")
document.onmousedown = getEvent;
</Script>

例2:
<Script>

function getCoordinate(evnt) {

if (document.all) {
    x = event.screenX;
    y = event.screenY;
}
else {
    x = evnt.screenX;
    y = evnt.screenY;
}
status = "水平坐標(biāo):"+ x + ";垂直坐標(biāo):"+ y;
}

document.onmousemove = getCoordinate;

</Script>

例3:
<Script>

function whichKey(evnt) {

if (document.all) {
     x = event.button;
     if( x==1 ) alert("你單擊了左鍵");
     if( x==2 ) alert("你單擊了右鍵");
}

else {
     x = evnt.button;
     if( x==1 ) alert("你單擊了左鍵");
     if( x==3 ) alert("你單擊了右鍵");
     return false;
}
}

document.onmousedown = whichKey;
document.write("請(qǐng)單擊鼠標(biāo)左/右鍵");

</Script>

 
  • 歷史對(duì)象:

    用以存儲(chǔ)客戶端最近訪問(wèn)的網(wǎng)址清單。

    格式:

    history.屬性
    history.方法(參數(shù))

  • 歷史對(duì)象的屬性:

    current 當(dāng)前歷史記錄的網(wǎng)址
    length 存儲(chǔ)在記錄清單中的網(wǎng)址數(shù)目
    next 下一個(gè)歷史記錄的網(wǎng)址
    previous 上一個(gè)歷史記錄的網(wǎng)址
  • 歷史對(duì)象的方法:

    back() 回到上一個(gè)歷史記錄中的網(wǎng)址
    forward() 回到下一個(gè)歷史記錄中的網(wǎng)址
    go(整數(shù)或URL) 前往歷史記錄中的網(wǎng)址

例1:
history.go(-1)

newWin.history.back()

parent.downFrame.histroy.back()

例2:
<A HREF="#" onClick="history.back()">上一頁(yè)</A>

<A HREF="javascript:history.back()">上一頁(yè)</A>

 
  • 位置對(duì)象:

    用來(lái)代表特定窗口的URL信息。

    格式:

    location.屬性
    location.方法(參數(shù))

  • URL的格式:

    protocol//host:port/path#hash?search
  • URL的種類:

    javascript: javascript程序代碼
    view-source: 顯示源代碼
    http:
    file:
    ftp:
    mailto:
    news:
    gopher
  • 位置對(duì)象的屬性:

    hash 錨點(diǎn)名稱
    host 主機(jī)名稱
    hostname host:port
    href 完整的URL字符串
    pathname 路徑
    port 端口
    protocol 協(xié)議
    search 查詢信息
  • 位置對(duì)象的方法:

    reload() 重新加載
    replace(網(wǎng)址) 用指定的網(wǎng)頁(yè)取代當(dāng)前網(wǎng)頁(yè)

例1:

按下按鈕前往「文哥網(wǎng)絡(luò)技術(shù)學(xué)習(xí)網(wǎng)」<P>
<INPUT TYPE="button" VALUE="走吧!" onClick="location.>

例2:

<FONT COLOR="red"
onClick="location='http://www.hubert.idv.tw/'">
文哥網(wǎng)絡(luò)技術(shù)學(xué)習(xí)網(wǎng)</FONT><P>

<FONT COLOR="blue" STYLE="cursor:hand"
onClick="location='http://www.hubert.idv.tw/'">
文哥網(wǎng)絡(luò)技術(shù)學(xué)習(xí)網(wǎng)</FONT>

例3:
<Script>

var sec = 5;

function countDown() {
if (sec > 0) {
     num.innerHTML = sec--;
}
else
     location = "http://www.hubert.idv.tw/";
}
</Script>

<BODY onLoad="setInterval('countDown()', 1000)">
<CENTER>
文哥網(wǎng)絡(luò)技術(shù)學(xué)習(xí)網(wǎng)
<H2>http://www.hubert.idv.tw/</H2>
五秒鐘后自動(dòng)帶你前往<BR>
<FONT ID="num" SIZE="7" FACE="impact">5</FONT>

例4:

<A HREF="#" onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.hubert.idv.tw/');"><FONT COLOR="red"><U>設(shè)為首頁(yè)</U></FONT></A><P>

<A HREF="javascript:window.external.AddFavorite('http://www.hubert.idv.tw /', '文哥網(wǎng)絡(luò)技術(shù)學(xué)習(xí)網(wǎng)');"><FONT COLOR="red"><U>加入收藏</U></FONT></A>



ExtJS教程- Hibernate教程-Struts2 教程-Lucene教程