javascript 瀏覽器安全色性心得

來源:互聯網
上載者:User

試用登入http://121.18.78.216/
javascript 瀏覽器安全色性心得(IE、Fixfox、Safari、Opera核心的瀏覽器)

感謝cindysaj的分享http://cindysaj.iteye.com/blog/696723

1、指令碼中px 一定要加上,否則Fixfox、Safari、Opera可能有問題

2、擷取對象 使用getElementById 均支援 盡量不要使用document.all或document.form等集合方法

3、window.event

(1)  通用寫法

<input type=”button” name=”someButton” value=”提交” onclick=”javascript:gotoSubmit(event)”/>

<script language=”javascript”>
function gotoSubmit(evt) {
evt = evt ? evt : (window.event ? window.event : null);

alert(evt);              // use evt

}
</script>

(2)event.clientX和event.clientY屬性 通用

(3)even對象 通用var el=evt.srcElement || evt.target;

(4)keyCode問題,正確寫法:

    var UA=navigator.userAgent;
    if (/msie/i.test(UA) || /opera/i.test(UA)){
        return String.fromCharCode(evt.keyCode);
    }else{
        return String.fromCharCode(evt.charCode);
    }

4、事件function通用寫法 如:

  document.onclick=function(event) {
    var evt = null;
    if (arguments.length==1){
        evt=arguments[0];
    }else{
     evt = (window.event ? window.event : null);
    }

    alert(evt); 
}

5、標籤的x和y的座標位置 通用:object.offsetLeft 和 object.offsetTop

6、表單的高度和寬度 document.body.clientWidth和document.body.clientHeight

7、添加事件
IE:element.attachEvent(”onclick”, func);。
FF:element.addEventListener(”click”, func, true)。
通用:element.onclick=func。雖然都可以使用onclick事件,但是onclick和上面兩種方法的效果是不一樣的,onclick只有執行一個過程,而attachEvent和addEventListener執行的是一個過程列表,也就是多個過程。例如:element.attachEvent(”onclick”, func1);element.attachEvent(”onclick”, func2)這樣func1和func2都會被執行。

8、父節點、子節點 通用parentNode、parentNode.childNodes

標籤的自訂屬性

9、關於frame 需要寫上id和name

擷取frame對象,通用寫法:window.frames["idORname"]

但是要調整frame屬性,最好採用getElementById("id")

10、showModalDialog

都支援,但是參數通用寫法如center:1; 如:

Opera不能彈出表單,Safria不能置中,需要自己定義left和top,

通用寫法:

function openDialog(url, width, height)
{
    var top = (window.screen.availHeight-height) / 2;
    var left = (window.screen.availWidth-width) / 2;
    var UA=navigator.userAgent;
    if (/gecko/i.test(UA) || /opera/i.test(UA)){
        window.open(url, "", "height="+height+"px,width="+width+"px,menubar=0,toolbar=0,status=1,resizable=1,scrollbars=1,top="+top+"px,left="+left+"px");
    }else{
       return window.showModalDialog(url, "", "dialogWidth:" + width + "px;" + "dialogHeight:" + height + "px;resizable:1;status:0;menubar:0;scrollbars:1;titlebar:0;toolbar:0;center:1;help:0;left:"+left+"px;top:"+top+"px;");
}

 

不要使用showModelessDialog(僅IE支援)
}

11、innerHTML(innerText FF不支援)

12、自訂屬性
IE:如果給標籤div1定義了一個屬性value,可以div1.value和div1[”value”]取得該值。
FF:不能用div1.value和div1[”value”]取。
通用:div1.getAttribute(”value”)。

 

構建一個WEB開發的基礎架構(主要包括資料庫處理、頁面架構及工具類)

一、架構實現了基於XML定製的列表查詢及圖表展現

二、列表實現了複雜查詢條件、合并行列(分組求和的處理)、合計列及切入資料和圖表的切入

三、編輯配置支援單表資料的增加和修改,針對開發人員實現的編輯頁面可方便擴充主表新增欄位

 

試用請登入http://121.18.78.216/
帳戶admin密碼admin

聯繫我們

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