Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of event event handling in firefox

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about an example analysis of event handling in firefox. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

When angularJs is used to implement a function, click to obtain the x and y coordinates of the event, the function is normal under IE9, chrome. Firefox event is undefined. The initial code is as follows:

html:

addRes

js:

$scope.addResPop = function () { var x = window.event.screenX;//ff Report undefined .... }

As a result, the console reported an error after clicking ff. After checking the data, we know that the differences of browser event objects are as follows:

1. In IE, event can be used as an attribute of window object directly.

In the W3 standard,event objects must be passed as parameters to event handlers, provided that they are used in our code. So, to access event objects in standard compatible browsers (Mozilla,Safari,Opera), do this:

addRes $scope.addResPop = function($event) { .... }

Note that angular $event is used here, which blocks browser compatibility issues for developers. It uses jQuery to bind click event, and the result of obtaining event object is exactly the same as $event obtained by angular, for example:

$("body").click(function(event){ ...... })

Understand browser compatibility issues and use the Tripartite Library to shield common compatibility issues.

Thank you for reading! About "firefox event handling example analysis" This article is shared here, I hope the above content can be of some help to everyone, so that we can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report