开发者

Adding click event to Window or document buggy in IE

开发者 https://www.devze.com 2023-04-07 16:10 出处:网络
Using the prevel framework to add a event is done like below pl(window).bind(\"eventname\",handlerFunction);

Using the prevel framework to add a event is done like below pl(window).bind("eventname",handlerFunction);

So I did this

pl(window).bind("click", function (ev) {
    if (ev.which == 1) {
        alert("Clicked");
    }
});

On clicking the document or window I was able to alert the string, but heck IE8 does not do the same. Is the Library broken or am I wrong with respect to IE. Prevel Javascript framework can be found here https:开发者_如何学C//github.com/chernikovalexey/Prevel here is the code that should get you working http://jsfiddle.net/pKhHJ/


The code "ev.which" is specific to firefox. For IE you have to use the code as "ev.keyCode". Try the code as shown below

pl(window).bind("click", function (ev) {
    if(!ev)
        ev = window.event;
  var kCode = ev.which || ev.keyCode;
    if (kCode == 1) {
        alert("Clicked");
    }
});

Hope this helps you.


It's fixed already, as I see.

0

精彩评论

暂无评论...
验证码 换一张
取 消