mutation-events

DOMNodeInserted in the IE

橙三吉。 提交于 2020-01-24 00:55:07
问题 Why doesn't this code work in IE? Please help fix it: jQuery('body').live('DOMNodeInserted',function(e){ var parent = jQuery(e.target).parent(); parent.find("a").css('color','#AA62C6'); parent.find('a').removeAttr('onmousedown'); }); 回答1: This event is not supported in IE. This is added to IE9 but seems to be buggy in the implementation. A solution will be to handle the dom manipulation at the base(The method which is changing the dom) level. function update(){ //do some dom manipulation $

How do I use mutationobserver instead of mutation events?

大兔子大兔子 提交于 2020-01-04 03:38:54
问题 I am trying to create my first streamgraph with D3.js. I am starting with a working example which incorporates a tooltip from code posted on-line, http://bl.ocks.org/WillTurman/4631136: When I copy the index.html and data.csv files to my PC (Windows 7), I am able to see the streamgraph in a browser (Firefox). However, I get a JS warning, " Use of Mutation Events is deprecated. Use MutationObserver instead. " What lines of code correspond to the Mutation Event? And how should I edit them to

How to check browser support for capabilities / events?

北城以北 提交于 2020-01-04 02:44:31
问题 In the past we used browser sniffing to infer if certain events or capabilities were available. I understand that browser sniffing has been 'deprecated' or 'shunned' in favor of feature sniffing. I would like to know how I can check if a certain event can be handled. Take DOMNodeInserted for example. It is supported by Chrome, FF and Safari, but not by IE. How can I sniff if this event is available? Is there a library present? How do you guys do proper feature sniffing? 回答1: You can't detect

How do I play a sound when an element changes, like SO Chat does?

拟墨画扇 提交于 2020-01-01 04:38:06
问题 I want a sound to play when an element changes on a page. I know how to do this, but I can't get it to play only on the first change , and don't do it later, until the user focuses the window (tab) and blurs it again. My current code: var notif = new Audio('http://cycle1500.com/sounds/infbego.wav'); if (window.innerHeight === window.outerHeight) { $(window).bind('DOMNodeInserted', function() { notif.play(); }); } 回答1: Use a variable to represent whether the sound should be played or not. var

Feature-detect: mutation-event availability in JavaScript?

冷暖自知 提交于 2019-12-22 04:36:21
问题 How can my JavaScript detect if an event is available? I'm aware of some great event-compatibility tables, but I need to use feature detection, not browser-sniffing plus a lookup table. Specifically, my JS makes great use of the DOM mutation events ( DOMNodeInserted and DOMSubtreeModified ) -- which work great in all browsers except (of course) Internet Explorer. So, how would I detect if a browser supports DOMNodeInserted ? 回答1: If you just want to check if the browser supports mutation

Jquery - run function when DOM element is added

假如想象 提交于 2019-12-18 05:18:22
问题 I have a website with jQuery and jQuery UI. I have a Javascript function: function ToButton() { $(".ToButton").button(); } This function runing after the page load and change all elements with class "ToButton". Also I change HTML code when user press a button. E.g.: $("body").append('<span class="ToButton">Test Button</span>'); And I want to run ToButton function to this new element too, but live or delegate methods in jQuery don't have "show" or "create" event type. So I need call function

Listening to events of a contenteditable HTML element

▼魔方 西西 提交于 2019-12-17 15:59:05
问题 I'm trying to figure out if there is any way to listen to events like focus or change of an HTML element with contenteditable attribute. I have this html markup: <p id="test" contenteditable >Hello World</p> I've tried these without any success(JSBin): var test = document.querySelector('#test'); test.addEventListener('change', function(){ alert('content edited'); }, false); test.addEventListener('DOMCharacterDataModified', function(){ alert('content edited'); }, false); test.addEventListener(

DOMNodeInserted equivalent in IE?

好久不见. 提交于 2019-12-17 02:51:30
问题 Other than using a timer to count the number of elements over time and looking for changes, I can't think of a better way to simulate this event. Is there some sort of proprietary IE version of DOMNodeInserted? Thanks. 回答1: No, there isn't. The nearest is the propertychange event, which fires in response to a change in an attribute or CSS property of an element. It fires in response to changing the innerHTML property of an element directly but not when the contents of the elements are altered

DOMNodeInserted equivalent in IE?

自作多情 提交于 2019-12-17 02:51:14
问题 Other than using a timer to count the number of elements over time and looking for changes, I can't think of a better way to simulate this event. Is there some sort of proprietary IE version of DOMNodeInserted? Thanks. 回答1: No, there isn't. The nearest is the propertychange event, which fires in response to a change in an attribute or CSS property of an element. It fires in response to changing the innerHTML property of an element directly but not when the contents of the elements are altered

Possible to modify DOM during/before initial DOM parsing?

两盒软妹~` 提交于 2019-12-13 18:40:14
问题 Is it possible to modify the DOM during or before the initial DOM parsing? Or do I have to wait until the DOM is parsed and built before interacting with it? More specifically, is it possible to hinder a script element in DOM from running using userscripts/content scripts or similar in chrome or firefox? Tried using eventListeners on DOMNodeInserted before the DOM is parsed, but these are only fired after the DOM is built. 回答1: These are two separate questions: 1. Is it possible to modify the