日期:2014-05-16  浏览次数:20323 次

帮忙看google搜索框自动提示代码(续前贴+100分=200分)
http://blog.csdn.net/RunUpwind/archive/2007/05/24/1623859.aspx

希望有javaScript高手静下心来仔细研究一下.
如果你做了,不要忘了在两个贴子都回复,以便给分.
另一贴是:http://community.csdn.net/Expert/topic/5557/5557283.xml?temp=.14555

------解决方案--------------------
ff也有cancelBubble
只不过window.event FF没它。。
获取event就可以了。。
方法可以用。

var reEvent = function () {
return window.event ? window.event : (function (o) {
do {
o = o.caller;
} while (o && !/^\[object[ A-Za-z]*Event\]$/.test(o.arguments[0]));
return o.arguments[0];
})(this.reEvent);
};
------解决方案--------------------
<script type= "text/javascript ">
Object.reEvent = function () {
return window.event ? window.event : (function (o) {
do {
o = o.caller;
} while (o && !/^\[object[ A-Za-z]*Event\]$/.test(o.arguments[0]));
return o.arguments[0];
})(this.reEvent);
};

var show = function (a) {
var e = Object.reEvent();
if (a) e.cancelBubble = true;
};
</script>
<div style= "width:100px; height:100px; background-color:#0099CC; border:#CCCCCC 1px solid; " onclick= "alert( '我是外面的 ') ">
<div style= "width:100px; height:30px; background-color:#F4F4F4; border:#CCCCCC 1px solid; " onclick= "show(true) "> &nbsp; </div>
<div style= "width:100px; height:30px; background-color:#FFF7FB; border:#CCCCCC 1px solid; " onclick= "show(false) "> &nbsp; </div>
</div>
------解决方案--------------------
Object.reEvent
这个方法必须要在函数里使用才可以。
------解决方案--------------------
你把代码弄成可以测试的demo贴上来。。。
------解决方案--------------------
参考:
<body>
<div id= "divParent " style= "background-color: #ffff00; width: 200px; height: 200px; "> Parent!
<div id= "divChild " style= "background-color: #00ffff; width: 100px; height: 100px; ">
Child!
</div>
</div>
<script type= "text/javascript ">
<!--
var oParent = document.getElementById( "divParent ");
var oChild = document.getElementById( "divChild ");
oParent.onclick = function(){
alert( "Parent ");
}
oChild.onclick = function(e)
{
e = e||window.event;
alert( "Child ");
// 停止冒泡!
// 注释看看效果有何不同!
e.cancelBubble = true;
};
//-->
</script>
</body>