javascript-events

visibilitychange event is not triggered when switching program/window with ALT+TAB or clicking in taskbar

ε祈祈猫儿з 提交于 2019-12-29 04:15:27
问题 Basically, the problem is with the behaviour of the event "visibilitychange". It's triggered: - When I switch to a different tab inside the browser window. When I click in minimize / restore buttons for the browser window. (this is ok) It's not triggered: - When I switch to a different window/program using ALT+TAB. When I switch to a different window/program clicking on taskbar. (this SHOULD trigger, because, just like when minimizing, the window's visibility may change) W3 Page Visibility

wait for document.body existence

寵の児 提交于 2019-12-28 18:11:14
问题 I wrote a chrome extension that works before the page is loaded (using the attribute "run_at": "document_start" ). The problem is that I want to add a div tag to the webpage body as soon as it is created. Before that document.body is null so I can't append tags to it. I don't care about full load of the body, I just need it to be existent. I am trying to find the best way to be alerted when the body tag in html is created (not loaded fully, just created). Is there any event handler for this

Javascript IE Event

依然范特西╮ 提交于 2019-12-28 06:57:29
问题 This works in Firefox, but not IE. Any help would be much appreciated! Thanks! var form = document.getElementById('theform') /* create the event handler */ form.gen.onclick = function( evt ) { var f = evt.target.form var y = f.year.value var m = f.month.value genCalendar( document, y, m, 'theCalendar' ) } 回答1: To get the target of an event in both standards compliant browsers and IE, use var target = evt ? evt.target : window.event.srcElement; There's an overview of the different properties

Dom loaded event cross borwser native javascript code

雨燕双飞 提交于 2019-12-28 06:53:34
问题 I'm working without the javascript framework, but I want to call a function just when the DOM is loaded. I can't/don't want to use the attribute 'onload' on the < body > tag. 回答1: Here is the code: in non-IE browsers, use DOMContentLoaded event in IE top frame use scroll hack (see _readyIEtop) in IE frame, simply use onload var onready = function(handler) { // window is loaded already - just run the handler if(document && document.readyState==="complete") return handler(); // non-IE:

IE8 & IE7 onchange event is triggered only after repeated selection

做~自己de王妃 提交于 2019-12-28 06:24:05
问题 I have a group of radio with an onchange handler: <input type="radio" name="Q12" value="radio" id="Q12_0" onchange="nextPnl('Q12');"> <br/> <input type="radio" name="Q12" value="radio" id="Q12_1" onchange="nextPnl('Q12');"> ​ function nextPnl(did) { document.write(did); }​ The problem is that in IE8 & IE7, the onchange event is triggered only after repeated selection. Please view this demo in IE's Developer Tools [Browser Mode] IE8: http://jsfiddle.net/3zwur/2/ 回答1: This is due to a bug with

IE8 & IE7 onchange event is triggered only after repeated selection

爱⌒轻易说出口 提交于 2019-12-28 06:23:10
问题 I have a group of radio with an onchange handler: <input type="radio" name="Q12" value="radio" id="Q12_0" onchange="nextPnl('Q12');"> <br/> <input type="radio" name="Q12" value="radio" id="Q12_1" onchange="nextPnl('Q12');"> ​ function nextPnl(did) { document.write(did); }​ The problem is that in IE8 & IE7, the onchange event is triggered only after repeated selection. Please view this demo in IE's Developer Tools [Browser Mode] IE8: http://jsfiddle.net/3zwur/2/ 回答1: This is due to a bug with

Scroll event is not fired inside directive - angular.js

偶尔善良 提交于 2019-12-28 05:58:05
问题 I'm stucked with problem. I have a directive for infinite-scroll where I listen for scroll event. The problem is that scroll event is only fired when I'm binding to $window : angular.element($window).bind('scroll', function () { console.log('Gogo!'); //works! }); element.bind('scroll', function () { console.log('Gogo!'); //doesn't work... :((( }); Directive is inside ng-view I found this question, looks very similar to my problem - Binding to events in a directive which is inside a ng-view

Is there a close event for the browser contextmenu

二次信任 提交于 2019-12-28 05:52:52
问题 I'm catching the contextmenu event using jQuery like this: $(document.body).on("contextmenu", function(e){ //do stuff here }); So far, so good. Now I want to execute some code when it closes but I can't seem to find a correct solution for this. Using something like the following would catch some of the cases, but not nearly all: $(document.body).on("contextmenu click", function(e){}); It wouldn't be executed when: the browser loses focus an option in the contextmenu is chosen the user clicks

Mozilla firefox not working with window.onbeforeunload

依然范特西╮ 提交于 2019-12-28 02:11:11
问题 I'm using window.onbeforeunload to display a message to the user on windows close, the function works well with chrome and IE but it doesn't work with Firefox, i'm using firefox version 26.0 i have tried many but with no mean, somebody said that its a bug in firefox as in this post and another suggests some solutions as in this post i tried all the solutions available using javascript and jquery but it doesn't work, now i display a confirm dialog but the browser default dialog appears after

JavaScript: How to simulate change event in internet explorer (delegation)

大城市里の小女人 提交于 2019-12-28 01:29:32
问题 UPDATE: (recap, fiddle and bounty) This question hasn't been getting too much attention, so I'm going to spend some rep on it. I know I tend to be overly verbose in both my answers and questions. That's why I went ahead and set up this fiddle, which is, in my view, a decent representation of the kind of code I'm currently having to use to come close to a bubbling change event. A couple of issues I'm trying to resolve: The pseudo-change event doesn't fire on a select element, unless it looses