獲取控件用document.getElementById,不用document.all(FF等瀏覽器不支持)2>

javascript IE與FireFox 一些兼容寫法

系統 3767 0

1>獲取控件用document.getElementById,不用document.all(FF等瀏覽器不支持)
2><button> 會被firefox解釋為提交form或者刷新頁面,需要寫標準<button type="button">
3>使用childNode()代替之前的children?
4> 手型鼠標指針請用cursor:pointer,不用 cursor:hand
5>獲取自己定義的屬性 用? document.getElementByID("TD1").getAttribute("isOBJ")? 代替document.getElementByID("TD1").isOBJ
6>事件追加方法attachEvent(IE)/detachEvent;addEventListener( Mozilla, Netscape, Firefox)/removeEventListener
? 又或者直接用obj.onmouseover=func;
7>Firefox中不存在 Event時間,必須通過object本身去取
?? 在Firefox獲取當前物件的坐標方法:
? document.onmousemove = Inti_move;
? function? Inti_move(ert)
{
? x=ert.pageX;
}

Internet Explorer Name Mozilla Name Description 表4 Mozilla與IE之間的事件屬性差異
altKey altKey Boolean property that returns whether the alt key was pressed during the event.
cancelBubble stopPropagation() Used to stop the event from bubbling farther up the tree.
clientX clientX The X coordinate of the event, in relation to the element viewport.
clientY clientY The Y coordinate of the event, in relation to the element viewport.
ctrlKey ctrlKey Boolean property that returns whether the Ctrl key was pressed during the event.
fromElement relatedTarget For mouse events, this is the element from which the mouse moved away.
keyCode keyCode For keyboard events, this is a number representing the key that was pressed. It is 0 for mouse events.
returnValue preventDefault() Used to prevent the event's default action from occurring.
screenX screenX The X coordinate of the event, in relation to the screen.
screenY screenY The Y coordinate of the event, in relation to the screen.
shiftKey shiftKey Boolean property that returns whether the Shift key was pressed during the event.
srcElement target The element to which the event was originally dispatched.
toElement currentTarget For mouse events, this is the element to which the mouse moved.
type type Returns the name of the event.


8>event.keyCode的問題解決
在FF中不存在window.event.keyCode屬性。可以用以下方法解決

function ?keepKeyNum(evt)
{
?
var ??k = window.event ? evt.keyCode:evt.which;
?????
if ?((k <= 57 )? && ?(k >= 48 ))
{ return ? true ;}
?????
else ?
{ return ? false ;}

? < input? type ="text" ?onKeyPress ="?return?keepKeyNum(event);" ? >

javascript IE與FireFox 一些兼容寫法


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 久久一级视频 | 国产一级特黄毛片在线毛片 | 男女久久久 | 日本高清免费在线视频 | 欧亚乱熟女一区二区在线 | 亚洲国产片高清在线观看 | 梦中人在线观看免费完整版 | 99九九精品视频 | 日本高清色本在线www | 爱爱视频在线观看 | 精品久久久一二三区 | 久久久精品一区二区三区 | 国产91一区二这在线播放 | 久草手机在线播放 | 亚洲欧美综合精品久久成人 | 九色网址| 欧美成人精品不卡视频在线观看 | 啪啪网页| 欧洲成人午夜免费大片 | 2022最新a精品视频在线观看 | 91精品观看91久久久久久国产 | 欧美在线亚洲 | 亚洲天天综合网 | 亚洲免费人成在线视频观看 | 天天操综合网 | 亚洲 欧美 日韩在线 | 亚洲精品久久久一二三区 | 亚洲一区二区三 | 亚洲精品免费在线 | 超碰在线观看97 | 国产亚洲欧美一区二区 | 日韩午夜激情视频 | 无名者电影在线完整版免费 | www.夜夜操.com | 夜夜爽99久久国产综合精品女不卡 | 天堂一区二区三区 | 国产中文字幕一区 | 亚洲精品成人 | 九色视频网 | 嫩草影院网影院在线 | 500av导航大全精品 |