`

xhtml mp的事件支持测试

    博客分类:
  • wap
阅读更多

以下是xhtml mp支持的事件,其中onload和onclick事件是规范规定浏览器必需支持的,其它为可选。具体哪种元素支持哪些事件,因浏览器不同而不同,可以修改以下代码进行测试。还附加了个XMLHttpRequest对象检测。

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!DOCTYPE html PUBLIC "-//OMA//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">  
  3. <html xmlns="http://www.w3.org/1999/xhtml">  
  4. <head>  
  5. <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />  
  6. <title>DOM Events Test For XHTML Mobile Profile</title>  
  7. </head>  
  8. <body>  
  9. ajax:<label id="ajax"></label><br />  
  10. onload:<label id="load"></label><br />  
  11. onunload:<label id="unload"></label><br />  
  12. onclick:<label id="click"></label><br />  
  13. ondblclick:<label id="doubleclick"></label>  
  14. onmousedown:<label id="mousedown"></label><br />  
  15. onmouseup:<label id="mouseup"></label>  
  16. onmouseover:<label id="mouseover"></label><br />  
  17. onmousemove:<label id="mousemove"></label>  
  18. onmouseout:<label id="mouseout"></label><br />  
  19. onfocus:<label id="focus"></label>  
  20. onblur:<label id="blur"></label><br />  
  21. onkeypress:<label id="keypress"></label>  
  22. onkeydown:<label id="keydown"></label><br />  
  23. onkeyup:<label id="keyup"></label>  
  24. onsubmit:<label id="submit"></label><br />  
  25. onreset:<label id="reset"></label>  
  26. onselect:<label id="select"></label><br />  
  27. onchange:<label id="change"></label><br />  
  28.   
  29. <form action="" method="get" id="f1">  
  30.   <input type="button" value="点击我" id="b1" />  
  31.   <input type="text" value="点击我" id="t1" />  
  32. </form>  
  33. <script type="text/javascript">  
  34. //<![CDATA[ 
  35.   /** 
  36.    * Ajax支持判断 
  37.    */ 
  38.   var xmlHttp; 
  39.   function createXMLHttp() 
  40.   { 
  41.     if (window.XMLHttpRequest) 
  42.     { 
  43.       xmlHttp = new XMLHttpRequest(); 
  44.     } 
  45.     else if (window.ActiveXObject) 
  46.     { 
  47.       try 
  48.       { 
  49.         xmlHttp = new ActiveXObject('Msxml2.XMLHTTP'); 
  50.       } 
  51.       catch(e) 
  52.       { 
  53.         try 
  54.         { 
  55.           xmlHttp = new ActiveXObject('Microsoft.XMLHTTP'); 
  56.         } 
  57.         catch(e) {}; 
  58.       } 
  59.     } 
  60.   } 
  61.   createXMLHttp(); 
  62.   if (xmlHttp) 
  63.   { 
  64.     document.getElementById('ajax').innerHTML = "支持"; 
  65.   } 
  66.   else 
  67.   { 
  68.     document.getElementById('ajax').innerHTML = "不支持"; 
  69.   } 
  70.   /** 
  71.    * 从这里开始 
  72.    */ 
  73.   function $(id) 
  74.   { 
  75.     return document.getElementById(id); 
  76.   } 
  77.   window.onload = function() 
  78.   { 
  79.     $('load').innerHTML = "支持"; 
  80.     if (window.onresize) 
  81.     { 
  82.       $('resize').innerHTML = "支持"; 
  83.     } 
  84.   } 
  85.   $('b1').onclick = function() 
  86.   { 
  87.     $('click').innerHTML = "支持"; 
  88.     $('f1').onsubmit(); 
  89.     $('f1').onreset(); 
  90.   } 
  91.   $('b1').ondblclick = function() 
  92.   { 
  93.     $('doubleclick').innerHTML = "支持"; 
  94.   } 
  95.   $('b1').onmousedown = function() 
  96.   { 
  97.     $('mousedown').innerHTML = "支持"; 
  98.   } 
  99.   $('b1').onmouseup = function() 
  100.   { 
  101.     $('mouseup').innerHTML = "支持"; 
  102.   } 
  103.     $('b1').onmouseover = function() 
  104.   { 
  105.     $('mouseover').innerHTML = "支持"; 
  106.   } 
  107.     $('b1').onmousemove = function() 
  108.   { 
  109.     $('mousemove').innerHTML = "支持"; 
  110.   } 
  111.     $('b1').onmouseout = function() 
  112.   { 
  113.     $('mouseout').innerHTML = "支持"; 
  114.   } 
  115.     $('t1').onkeydown = function() 
  116.   { 
  117.     $('keydown').innerHTML = "支持"; 
  118.   } 
  119.     $('t1').onkeypress = function() 
  120.   { 
  121.     $('keypress').innerHTML = "支持"; 
  122.   } 
  123.     $('t1').onkeyup = function() 
  124.   { 
  125.     $('keyup').innerHTML = "支持"; 
  126.   } 
  127.     $('t1').onfocus = function() 
  128.   { 
  129.     $('focus').innerHTML = "支持"; 
  130.   } 
  131.     $('t1').onblur = function() 
  132.   { 
  133.     $('blur').innerHTML = "支持"; 
  134.   } 
  135.     $('t1').onselect = function() 
  136.   { 
  137.     $('select').innerHTML = "支持"; 
  138.   } 
  139.     $('t1').onchange = function() 
  140.   { 
  141.     $('change').innerHTML = "支持"; 
  142.   } 
  143.     $('f1').onsubmit = function() 
  144.     { 
  145.         $('submit').innerHTML = "支持"; 
  146.         return false; 
  147.     } 
  148.     $('f1').onreset = function() 
  149.   { 
  150.     $('reset').innerHTML = "支持"; 
  151.     return false; 
  152.   } 
  153. //]]>  
  154. </script>  
  155. </body>  
  156. </html>  
分享到:
评论
1 楼 gundumw100 2010-06-13  
不是说wap2.0不可以使用Javascript脚本语言的吗!?

相关推荐

Global site tag (gtag.js) - Google Analytics