DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> 網頁教學網整理的Javascript的技巧代碼
網頁教學網整理的Javascript的技巧代碼
編輯:關於JavaScript     

事件源對象

event.srcElement.tagName
event.srcElement.type

捕獲釋放

event.srcElement.setCapture(); 
event.srcElement.releaseCapture();

事件按鍵

event.keyCode
event.shiftKey
event.altKey
event.ctrlKey

事件返回值

event.returnValue

鼠標位置

event.x
event.y

窗體活動元素

document.activeElement

綁定事件

document.captureEvents(Event.KEYDOWN);

訪問窗體元素

document.all("txt").focus();
document.all("txt").select();

窗體命令

document.execCommand

窗體COOKIE

document.cookie

菜單事件

document.oncontextmenu

創建元素

document.createElement("SPAN");

根據鼠標獲得元素:

document.elementFromPoint(event.x,event.y).tagName=="TD
document.elementFromPoint(event.x,event.y).appendChild(ms)

窗體圖片

document.images[索引]

窗體事件綁定

document.onmousedown=scrollwindow;

元素

document.窗體.elements[索引]

對象綁定事件

document.all.xxx.detachEvent('onclick',a);

插件數目

navigator.plugins

取變量類型

typeof($js_libpath) == "undefined"

下拉框
下拉框.options[索引]
下拉框.options.length

查找對象

document.getElementsByName("r1");
document.getElementById(id);

定時

timer=setInterval('scrollwindow()',delay);
clearInterval(timer);

UNCODE編碼

escape() ,unescape

父對象

obj.parentElement(dhtml)
obj.parentNode(dom)

交換表的行

TableID.moveRow(2,1)

替換CSS

document.all.csss.href = "a.css";

並排顯示

display:inline

隱藏焦點

hidefocus=true

根據寬度換行

style="word-break:break-all"
 
自動刷新

<meta HTTP-EQUIV="refresh" CONTENT="8;URL=http://www.poluoluo.com">

簡單郵件

<a  href="mailto:[email protected]?subject=ccc&body=xxxyyy"> 

快速轉到位置

obj.scrollIntoView(true)

<a name="first">
<a href="#first">anchors</a>

網頁傳遞參數

location.search();

可編輯

obj.contenteditable=true

執行菜單命令

obj.execCommand

雙字節字符

/[^\x00-\xff]/

漢字

/[\u4e00-\u9fa5]/

讓英文字符串超出表格寬度自動換行

word-wrap: break-word; word-break: break-all;

透明背景

<IFRAME src="1.htm" width=300 height=180 allowtransparency></iframe>

獲得style內容

obj.style.cssText

HTML標簽

document.documentElement.innerHTML

第一個style標簽

document.styleSheets[0]

style標簽裡的第一個樣式

document.styleSheets[0].rules[0]

防止點擊空鏈接時,頁面往往重置到頁首端。

<a href="javascript:function()">word</a>

上一網

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved