随笔 - 81  文章 - 1033  trackbacks - 0
<2007年4月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

在浮躁的年代里,我们进取心太切,患得患失;虚荣心太强,战战兢兢。一心争强好胜,惟恐榜上无名。
I think I can fly , and flying like a bird !
程序员一名,已售出,缺货中!

我的邮件联系方式

用且仅用于MSN

博客点击率
free web counter
free web counter

常用链接

留言簿(36)

随笔档案

搜索

  •  

积分与排名

  • 积分 - 185617
  • 排名 - 308

最新评论

阅读排行榜

评论排行榜

      IE(含IE6、IE7)下用程序触发鼠标点击事件显得很飘逸,一句代码而已,但它的不守规矩着实让我郁闷了一把。而FireFox则是遵循模型办事,代码多了几行不过清晰了很多。废话不多说,因为代码会说话:)。

 1 <html>
 2 <head><title>Dispatch Event Sample</title>
 3 <script>
 4 function clickABC(el){
 5   if (navigator.appVersion.match(/\bMSIE\b/)){
 6       el.click();
 7   }else{
 8       var evt = document.createEvent("MouseEvents");
 9       evt.initEvent("click"truetrue);
10       el.dispatchEvent(evt);
11   }
12 }
13 </script>
14 </head>
15 <body>
16 <div id="abc" onclick="javascript:alert('you are clicked Crespo Shi!');">I'm Crespo Shi</div>
17 <input type="button" onclick="javascript:clickABC(document.getElementById('abc'))" value="Dispatch Event"/>
18 </body>
19 </html>

      很多同学因为各种浏览器兼容的问题而觉得浏览器编程或者说JavaScript编程是一件很痛苦的事情,其实当你熟悉了常见的不兼容和利用了良好的JavaScript Lib你会发现也不是想象中那么郁闷,浏览器编程绝对是一件很享受的事情。
posted on 2007-04-04 15:19 cresposhi 阅读(7008) 评论(21)  编辑  收藏

FeedBack:
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现[未登录] 2007-04-04 17:00 Aqing
自己总结的“IE和Firefox在JavaScript方面的兼容性”:

IE和Firefox在JavaScript方面的兼容性  回复  更多评论
  
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现 2007-04-04 18:57 cresposhi
@Aqing
读了,不错,把我这个也加上吧,呵呵。  回复  更多评论
  
# re: 好象onmouseover在firefox下不能使用 2007-09-03 15:34 楊戩嵐
在用onmouseover的效果時,在IE下就可使用,但在firefox下就不行了。該如何修正這段代碼,使它可以在IE和firefox下都能使用。
<html>
<head>
</head>

<script language="javascript">
function smover(str)
{
var getid=str; //alert(getid);
eval('document.all.'+getid+'.style.pixelLeft=event.clientX+document.body.scrollLeft+10')
eval('document.all.'+getid+'.style.pixelTop=event.clientY+document.body.scrollTop+10')
eval('document.all.'+getid+'.style.visibility="visible"')

}
function smout(str)
{
var getid=str;
eval('document.all.'+getid+'.style.visibility="hidden"')
}
</script>
<body>
<form name="myform">
<table border='1'>
<tr onmouseover="smover('ap');" onMouseOut="smout('ap')">
<td>
APACHE COMPUTER
<img ID="ap" src="./images/email.gif" STYLE="position:absolute;TOP:0pt;LEFT:0pt;width=30;height=28;Z-INDEX:2;visibility:hidden;">
</td>
</tr>

<tr onmouseover="javascript:smover('kp');" onMouseOut="javascript:smout('kp')">
<td>
APACHE COMPUTER
<img ID="kp" src="./images/down.gif" STYLE="position:absolute;TOP:0pt;LEFT:0pt;width=30;height=28;Z-INDEX:2;visibility:hidden;">
</td>
</tr>
</table>
</body>
</html>

拜謝!  回复  更多评论
  
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现 2007-10-25 11:03 omeweb
这个问题估计你很难解决:

<a href="http://omeweb.com/" target="_blank" id="a"></a>

这个是一个连接,我要求的是这个页面一打开,就弹出了http://omeweb.com,IE和OPERA都可以搞定,就是FF不行。  回复  更多评论
  
# JS兼容问题求助 2008-04-14 14:50 绝世※好猫
你好,不知道你什么时候能看到留言.
========================
www.zhuaren.com

直接点搜索进去后的页面在FF下正常 在IE6 IE7下出现不同的错误.

主要是想实现 鼠标放到一个<td>上弹出一个<div>

我是用onmouseover(show(1,1))
show() 就是一个设置<div>的display属性的 1,是表示显示(0是隐藏) ,1是这个<td>的ID

<td>是用PHP的froeach循环出来的

<td>的ID是 document.getElementsByName('td_name') 找出所有<td> 然后$i++ 循环出ID

===================================
想麻烦你抽世间帮我看下 很急...

===================================
希望能回复到 http://hi.baidu.com/haomao

谢谢了!  回复  更多评论
  
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现 2008-04-14 15:16 绝世※好猫
你好 ! 谢谢你的回复..


在FF下 鼠标放到那些招聘职位的连接上 应该是要弹出一个层的

但是在IE7 和 IE6下 都不弹出来

浏览器下面显示错误啊

看见了吗  回复  更多评论
  
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现 2008-04-14 15:17 绝世※好猫
我在你的BLOG等者 你就在后面留吧  回复  更多评论
  
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现 2008-10-30 17:58 医手
FF下其实有件很郁闷的事, 那就是你这样弄出来的事件, 鼠标永远是在0,0  回复  更多评论
  
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现 2011-06-29 14:30 loan
Don't have cash to buy a car? Worry not, because this is possible to take the mortgage loans to resolve such problems. Thus take a term loan to buy everything you want.   回复  更多评论
  
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现 2011-07-06 20:33 custom research papers
Everything should be very well in your research career when students see the professional writing service to purchase essay in. Therefore that is affirmable to get term paper.  回复  更多评论
  
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现 2011-07-08 04:48 academic writing services
Do you opine that no one is ready to support you with your academic papers finishing? That's not right, just because speech and presentation writing company will assist you every time you need!   回复  更多评论
  
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现 2011-07-22 14:22 cheap research papers
That is valuable to buy cheap custom term paper to save free time. Thence guess several times just before you start to work on you essay.   回复  更多评论
  
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现 2011-07-22 17:31 essay papers
I apologize but I can't talk a lot. So I would just tell that the custom writing service can assist you with your assignment without difficulties.   回复  更多评论
  
# re: IE与FireFox下用程序触发鼠标点击事件不同的实现 2012-04-23 11:30 social bookmarking site
Our professionals support your website popularity. Choosing our social bookmarker service, you should be assured that we support you round the clock.   回复  更多评论
  
# cash advances 2012-08-09 12:13 cash advances
kagwpgs http://paydayloansstb.ca/ cash advances  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: