![]() If you want a simpler version without the propagation and default prevention options but with this and event normalization, that would be this: // add event cross browserĮlem. and make sure the event is passed to the fn also so that works the same tooĮlem.addEventListener(event, listenHandler, false) The addEventListener () method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. This can be used to alert the user in case some data is unsaved on the. Refactor code so all content/DOM access is grouped in a single object or file. set the this pointer same as addEventListener when fn is called The addEventListener () method is used to set up a function whenever a certain event. Here is a technique for writing an add-on that works in both Electrolysis and non-Electrolysis browsers (e.g. avoid memory overhead of new anonymous functions for every event handler that's installed gBrowser) + return + const tabContainer + t(domWindow, + helper.addEventListener(tabContainer. (gbrowser tabContainer childNodes item) x) gbrowser)))))) (defvar js-read-tab-history nil) (defun js-read-tab (prompt) Read a Mozilla tab with. In addition to make one function for adding event handlers, it also normalizes the this pointer and the events object so they can be treated the same in any browser too. It seems like it should just be a normal function. I also see that your addEvents function is a self executing function which doesn't make sense in this regard. That would be at least part of the problem. In your function, I see you are using both elemenet and element where they should be the same spelling. Your second way is almost the same except i don't understand the return. The most smiple way i think :- function test()įunction addEventsCrossBrowsers(elemenet,event,func)Įlemenet.addEventListener(event,func,false) Return elemenet.attachEvent("on"+event,func) ĮventsCrossBrowsers.addEvents(x,"click",test) links: PTS, VCS area: main in suites: wheezy size: 796,452 kB sloc: cpp: 3,181,607 ansic: 1,641,175 python: 167,590 java: 128,022. Return elemenet.addEventListener(event,func,false) I'm trying to add event listener to element x on event click function test() Clicking the button will enable Reader View for that page, and the icon will turn purple. When the add-on detects that a page is compatible with Reader View, the button will enable and the icon will turn blue. Window.My problem here:why doesn't this code work ?. links: PTS, VCS area: main in suites: wheezy size: 725,788 kB sloc: cpp: 2,944,471 ansic: 1,399,025 java: 141,587 python: 131,270 xml. This extension adds a button with the Reader Mode icon to the Pale Moon interface. Not only is it more portable for the different platforms, it can also save you coding time and save us time reviewing your codes. Error console logged: No chrome package registered for chrome://linkparser/content/browser.xul.Ħ) Use the prefwindow element () to manage your preferences (options.xul). This version doesn't work on Firefox 2.0. but i want to register only for main browser window resize event. ![]() Currently i'm using gBrowser.addEventListener ('resize',myfunction,false) Later i came to know this will register resize event for each tab of the browser. Error: gBrowser is not defined (LinkParser.js, Line 380)ĥ) Only Firefox versions that have been tested on and that you can give support to are to be included. i've written javascript that need to be notified for browser window resize event. Error: statusBarColor is null (LinkParser.js, Line 349) "LinkParser-statusBarColor".ģ) There is an undeclared variable "parsedURL" (LinkParser.js, Line 260) leaking to the global scope.Ĥ) On opening preferences (options.xul), error console logged: gBrowser. A good way is to prefix them like what was done for your other ids, i.e. And on right-clicking the icon, both menupopup id="statusBarContext" and the Options page showed up.Ģ) All XUL ids (statusBarColor, statusBarContext, statusBarParse) need to be uniquely named to prevent conflicts with other add-ons that may be installed by users. This version didn't pass full review because:ġ) On tab selection, the statusbarpanel (id=LinkParser-statusbar) didn't update to reflect the status of the current page. ![]() ![]() However, your add-on has been granted preliminary review and is now available for download in our gallery at Your add-on, LinkParser 1.0, has been reviewed by an editor and did not meet the criteria for full review. We will have to go back to the shed and work on it again Unfortunaltely it is not free of errors yet. Our new Firefox Plugin Linkparser made it into experimental mode on Mozilla so now it looks like this: ![]()
0 Comments
Leave a Reply. |