當(dāng)我們需要用到event事件的屬性或方法時(shí)有時(shí)候會(huì)這樣寫(xiě),如下列語(yǔ)句:...function func(e){var e = e?e:window.event;...}這個(gè)e放到函數(shù)里面作為一個(gè)參數(shù)到底什么意思,這種形式到底什么意思,有沒(méi)有關(guān)于這種用法形式原理的詳細(xì)解釋或者參考手冊(cè)?以下為通過(guò)這個(gè)方式寫(xiě)的一段代碼,firefox下報(bào)錯(cuò) ' e is undefined',錯(cuò)在哪里:(將該段代碼替換head頭的<script></script>標(biāo)簽即可)....<script type="text/javascript">window.onload = function(){a();}function cancelBubble(e){var e = e?e:window.event;if(window.event) e.cancleBubble = true;else e.stopPropagation(); ///////////報(bào)錯(cuò)點(diǎn): e is undefined}function a(e){var e = new event();alert(e);cancelBubble(e);}function b(){alert(1);}</script>....
關(guān)于JavaScript函數(shù)參數(shù)e?
慕的地6264312
2019-02-13 14:11:08