ieとfirefoxの違い
5696 ワード
<head>
<script type='text/javascript'>
function init() {
//
var handler = function(){
var host = document.location.href;
if(host.indexOf('jx163.cn') >= 0)
document.location = "/";
else ;
};
//
if (window.addEventListener) {
window.addEventListener('DOMContentLoaded', handler, false);
window.addEventListener('load', handler, false);
} else if (window.attachEvent)
window.attachEvent('onload', handler);
else
window.onload = handler;
} // end init
init();
</script>
</head>
<body>
--------------------
window firefox event
--------------------
<SCRIPT LANGUAGE="JavaScript">
<!--
function hh(e)
{
alert(arguments[0]);
e=window.event||e;
var el=e.srcElement||e.target;
alert(el.value);
}
//-->
</SCRIPT>
<INPUT id ="button2" value ="hahahahah" TYPE="button" onclick="hh(event);">
--------------------
test
--------------------
if(WebComm.getOS() == "MSIE")
{
obj.setCapture ();
}
else
{
document.addEventListener("mousemove",WebComm.MoveDiv,false);
}
if(WebComm.getOS() == "MSIE")
{
obj.releaseCapture ();
}
else
{
document.removeEventListener("mousemove",WebComm.MoveDiv,false);
}
------------------
1. innerText , 。 innerHTML innerText, , textContent innerText, , 。 textContent, HTML innerHTML
2. :
IE js:obj.onselectstart=function(){return false;}
CSS:-moz-user-select:none
3. ( : ):
IE:filter:alpha(opacity=10);
:-moz-opacity:.10;
4. :
IE:obj.setCapture() 、obj.releaseCapture()
: document.addEventListener("mousemove",mousemovefunction,true);
document.removeEventListener("mousemove",mousemovefunction,true);
5. :
IE:event.clientX、event.clientY
:
obj.onmousemove=function(ev){
X= ev.pageX;Y=ev.pageY;
}
6.DIV :
: div CSS::{width:100px;height:100px;border:#000000 1px solid;}
IE :div ( ):100px,div ( ):100px;
:div ( ):102px,div ( ):102px;
IE , js css , .
. :
var isIE=document.all? true:false;
, document.all isIE=true, isIE=false
. CSS :
!important css ( )
:{border-width:0px!important;border-width:1px;}
, IE 1px
XHTML JS、CSS , IE/ 。 XHTML , web , ! ASP.NET XHTML , , visual studio 。
, XHTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
JS CSS, N , XHTML :
1.document.documentElement document.body
CSS :document.documentElement
:document.documentElement.style.overflow='hidden';
overflow-X、overflow-Y XHTML ;
2. document.documentElement
(clientWidth、clientHeight、scrollLeft、scrollTop) document.documentElement
document.body.appendChild() document.body.removeChild() , document.documentElement.appendChild() document.documentElement.removeChild() ;
clientWidth、clientHeight、scrollLeft、scrollTop document.documentElement.style document.documentElement
3. , IE , , XHTML ——
:
div CSS::{width:100px;height:100px;border:#000000 1px solid;}
IE ( ):div ( ):100px,div ( ):100px;
( )::div ( ):102px,div ( ):102px;
XHTML (IE ,^_^):
IE (XHTML):div ( ):102px,div ( ):102px;
(XHTML)::div ( ):102px,div ( ):102px;
--------------------
IE attachEvent , FireFox addEventListener 。
addEventListener , :
element.addEventListener(type,listener,useCapture)
element 。
type , "onclick" "click","onblur" "blur", "on"。
listener ,
, , addEventListener 3 (useCapture)。
userCapture true, Capture, false bubbing 。 false, 。
html
<div id="div_test"> <input type="button" id="btn_test" value="se4.cn " /> </div>
window.onload=function(){ document.getElementById("div_test").addEventListener("click",test1,false); document.getElementById("btn_test").addEventListener("click",test2,false); } function test1(){ alert(" div ") } function test2(){ alert(" input ") }
userCapture true test1 , userCapture false test2 。
#Javascript