dom-events

Disable hardware back button in Ionic application?

青春壹個敷衍的年華 提交于 2019-12-03 18:46:16
问题 I'm trying to disable the back button on my Cordova app. I'm using AngularJS + Ionic Framework. I found topics about this and tried the code bellow, but it has absolutely no effect. Any idea? index.html <head> <script> document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { document.addEventListener("backbutton", function (e) { e.preventDefault(); console.log("hello"); }, false ); } </script> </head> Note that when I push back button, I have "hello"

Record and replay Javascript

帅比萌擦擦* 提交于 2019-12-03 18:44:09
问题 I know it is possible to record mouse movements, scrolling and keystrokes. But what about changes to the document? How can I record changes to the document? Here is my try out. There must be a better more simple way to store all events? I am thankful for all tips I can get! <!DOCTYPE html> <html> <head> <title>Record And replay javascript</title> </head> <body id="if_no_other_id_exist"> <div style="height:100px;background:#0F0" id="test1">click me</div> <div style="height:100px;background:

Unable to perform click action in selenium python

让人想犯罪 __ 提交于 2019-12-03 18:03:46
问题 I'm writing a test script using selenium in python. I have a web-page containing a tree-view object like this: I want to traverse over the menu to go to the desired directory. Respective HTML code for plus/minus indications is this: <a onclick="changeTree('tree', 'close.gif', 'open.gif');"> <img id="someid" src="open.gif" /> </a> The src attribute of the image can be either open.gif or close.gif . I can detect weather there is a plus or minus by simply checking the src attribute of the img

pagehide and pageshow events don't work as expected on ios chrome

故事扮演 提交于 2019-12-03 17:37:05
问题 Apple documentation lists down the available iOS browser events here: https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html The 'pagehide' and 'pageshow' events seem to work fine on safari, but on chrome it only works on page load and unload. It doesn't work on: Pressing the home button, i.e. sending Chrome to background Switching tabs Below is a small Javascript snippet that you can use to verify it: <script

JavaScript key handling and browser compatibility

核能气质少年 提交于 2019-12-03 17:19:50
问题 I'm working on key handling in Javascript. I have done some research and I'd like to know whether I have a correct understanding of key handling. KeyDown/KeyUp Event The key down and key up events are supported by IE7+ and Firefox 3.5+ I didn't check the earlier versions of the browsers, but I guess that they also support these events. Is it correct to say that each key on the keyboard will always have a keycode. CharCode CharCode value is available on the keypress.Majority of the keys will

Cross-browser: detect blur event on window

纵然是瞬间 提交于 2019-12-03 16:45:02
问题 I just read, I think all the thread that deals with this subject, and I can't find a real solution to my problem. I need to detect when the browser window loses its focus, i.e. a blur event. I've tried all the scripts on stackoverflow, but there doesn't seem to be a proper cross-browser approach. Firefox is the problematic browser here. A common approach using jQuery is: window.onblur = function() { console.log('blur'); } //Or the jQuery equivalent: jQuery(window).blur(function(){ console.log

Get horizontal scroll event in js

邮差的信 提交于 2019-12-03 16:40:25
问题 What I want to do, is to catch the event when the user is scrolling div horizontally. For vertical scroll I am using event 'mousewheel' and it's working properly. ( horizontal scroll is performed by a two finger drag on the touchpad - I am testing on Mac OS). 回答1: You can handle horizontal scrolling by : $("#someContainer").on("scroll", function (e) { horizontal = e.currentTarget.scrollLeft; vertical = e.currentTarget.scrollTop; }); In this case this bind all kind of scroll events on this

Pagehide event on imminent tab switching in Mobile Safari does not fire when running on iPad

ⅰ亾dé卋堺 提交于 2019-12-03 16:25:12
问题 It is well know that Mobile Safari pauses Javascript execution on a webpage when you switch to different browser tab switch to a different iOS app (e.g. when you get an incoming call the phone app) You can subscribe to the window's "pagehide" and "pageshow" events to detect imminent suspension and reactivation of Javascript. The problem is, those events do not fire when tab-switching (1.) on an iPad Mobile Safari. On an iPhone Mobile Safari everything is fine , just as described above. It's

HTML 5 drag events

梦想与她 提交于 2019-12-03 15:47:32
I am trying to build a reorderable list in JS and HTML. (trying to do it without using jQuery ui ) I can't seem to figure out why only the dragstart and dragend events fire when a list item is dragged. Anyone know why the other events not firing? <ul> <li draggable="true" class="drag">1111111</li> <li draggable="true" class="drag">222222</li> <li draggable="true" class="drag">333333</li> <li draggable="true" class="drag">444444</li> </ul> <script type="text/javascript"> var drags = document.querySelectorAll('.drag'); [].forEach.call(drags, function(drag) { drag.addEventListener('dragstart',

Removing event listeners as Class.prototype functions

99封情书 提交于 2019-12-03 15:39:55
I'm trying to have a Class.prototype based classes in my project, where I don't have inline functions. Considering this example, it's impossible to remove the eventListener on myVideo video object, that I have in my class. This is a theoretical example, not an actual production code I have. var myClass = function () { this.initialize(); } MyClass.prototype.myVideo = null; MyClass.prototype.initialize = function () { this.myVideo = document.getElementById("myVideo"); this.myVideo.addEventListener("ended", this.onMyVideoEnded, false); this.myVideo.play(); } MyClass.prototype.onMyVideoEnded =