javascript-events

Chrome Extension: How to reload/re-execute content script on Ajax request

别等时光非礼了梦想. 提交于 2019-12-12 08:08:26
问题 I'm trying to execute a content script for a certain site (inject a button or change the link) however I would like to do this as the user browses the website. The problem is that the web page is built dynamically with ajax requests as the user browses. I had solved this earlier in an extension I had written by actually injecting my javascript into the web page. I was wondering whether there is a better alternative of just being able to register for an ajaxComplete event or something similar

add/remove listeners on javascript ( garbage collector )

半世苍凉 提交于 2019-12-12 08:07:36
问题 I have a quick question regarding on adding/removing listeners of a DOM object. I would like to ask if the garbage collector be able to collect the memory when removing elements from the page. ex. a <ul> tag with a couple list of children( <li> ) var ul = document.getElementById('someParent'); var children = ul.children; var someFunction = function() {}; for(var i = 0; i < children.length; i++) { children[i].addEventListener('click', someFunction); } // This is where I am not sure, would the

How to open option list of HTML select tag on onfocus()

半腔热情 提交于 2019-12-12 07:36:21
问题 My HTML code looks like below. <select id = "demo2"> <option value = "---select---">---select---</option> <option value = "1">Oranges</option> <option value = "2">Apples</option> <option value = "3">Pears</option> <option value = "4">Kiwis</option> <option value = "5">Bananas</option> <option value = "6">Banansasas</option> <option value = "7">Grapes</option> </select> How do I open the option list of the select tag on onfocus() events? 回答1: $(document).ready(function(){ $('select').focus

In JQuery when should you use .bind() over .click() - or any other given event?

浪尽此生 提交于 2019-12-12 07:34:57
问题 I understand the difference between Live and Bind but when should I use use .bind() over a 'standard' event method as shown below. Are there any key differences in the way these two calls work? $('.clickme').bind('click', function() { // Handler called. }); $('.clickme').click(function() { // Handler called. }); 回答1: They're effectively the same. However, using bind() allows you to make use of namespaced events. This is especially useful when writing plugins. 回答2: in "bind" you can use

javascript textbox call event when value changes

扶醉桌前 提交于 2019-12-12 07:21:45
问题 I have a textbox, and whenever the value of the box changes, I want to check and see if 20 digits have been entered. I thought that I would use the onChange event, but this seems to be interpreted as the onBlur event on IE. So then I thought I would use onKeyDown, but the problem comes in if the user wants to paste a value into the field, then the function never gets called. There are no other form boxes so I can't rely on onBlur or expect that they will change focus ever. How do I do this? I

Wordpress and Google Analytics Events

拥有回忆 提交于 2019-12-12 05:49:12
问题 I want to track some actions in Google Analytics but I can't get it working. I tried it with Contact Forms (Wordpress). At the additional settings I just wrote: on_sent_ok: "ga('send', 'event', 'Formular-Beratung', 'sent');" but it does not work. I installed the Google tag assistant, but I cant see any event (not even in the live view at Google Analytics). Next: There is a live chat (snapengage). Here you can also track events. For this I implemented the code var seAgent; SnapABug.setCallback

Dropdown not opening when using focus and focusout

丶灬走出姿态 提交于 2019-12-12 05:48:01
问题 I have two dropdowns with same the same class let’s call it dropdown and I do this fiddle with the dropdowns with jquery: $('.dropdown').focus(function () { //Fiddle with this dropdown }).focusout(function () { //Fiddle with this dropdown }); When I jump between two dropdowns with the same class (dropdown) the drop down doesn’t open immediately instead it get focus and I have to click on it again in order to open it up. It seem to have something to do with the fact that I enable and disable

Prevent Javascript function from firing multiple times

萝らか妹 提交于 2019-12-12 05:31:49
问题 jsFiddle I use a customized drop-down menu which runs on jquery events and animations. The problem occurs when I activate the drop-down via mouseenter several times, which results in the menu sliding down then sliding up several times. I tried to fix it by adding .stop(true), which was successful, but it resulted in other problems like this. I followed that advice(jsFiddle Here), but it causes more unattractive problems. I need is a way to stop a function from firing redundantly, but still be

Event Handler Called With Wrong Context

安稳与你 提交于 2019-12-12 05:28:40
问题 In the SomeObj object, the onkeydown event handler this.doSomething is called in the wrong context (that of the textbox element) but it needs to be called in the context of this . How can this be done? function SomeObj(elem1, elem2) { this.textboxElem = elem1; this.someElem = elem2; this.registerEvent(); } SomeObj.prototype = { registerEvent: function() { this.textboxElem.onkeydown = this.doSomething; }, doSomething: function() { // this must not be textboxElem alert(this); this.someElem

JQuery switching application from “live” to “on” method [duplicate]

天涯浪子 提交于 2019-12-12 05:18:38
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: jQuery 1.7 - Turning live() into on() Just switching my code from "live" to "on" and some events just don't fire any more, here is an example, can anyone pls help out saying what's wrong with it? It WORKED 100% correct with "live" instead of "on" method before.... $('a#doBulkLink').on('click', function (e) { createLabelsWithDestinationFolders(); $('label.moveDocDestinationFolder').on('click', function (e) {