dom-events

How to add function on button in phonegap?

半城伤御伤魂 提交于 2019-12-05 02:31:48
I'm new to Phonegap and I want to develop a Phonegap application for Android.. I want to give some function on button click on my html.. I've tried this code but it does not work: index.html <!DOCTYPE HTML> <html> <head> <title>PhoneGap</title> <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> <script type="text/javascript" charset="utf-8" src="mycode.js"></script> </head> <body onload="init();> <h1>Hello World</h1> <form> <input type="button" value="Click me" onclick="msg()" /> </form> </body> </html> mycode.js function init() { // the next line makes it impossible to

Mobile Safari sometimes does not trigger the click event

可紊 提交于 2019-12-05 01:54:43
This is a dynamic JavaScript application I am working on. I have many <a> anchor elements that have a class. When that class is clicked, something should happen. This works fine in Firefox, Chrome, IE, but in some cases the click event is not triggered on mobile Safari (iPad and iPhone). These elements all have exactly the same CSS, it's just their position that differs (they are in different containers). I tried various solutions that I found here but with no luck. For instance: setting the cursor to pointer the code in this answer Do you have any other idea that might help me find a solution

See all dom events for an element

南笙酒味 提交于 2019-12-04 20:45:24
问题 I have a jQuery UI datepicker that, when you click on a date, clears my URL hash to # , and doesn't change the date in the textbox. I assume there's some other JavaScript utility somewhere that has some sort of delegated event that's also being called, throwing an error, and killing the jquery handler. How can I step through, and or see all delegated events match this dom element . 回答1: Chrome's dev tools can help with this: Point Chrome at the page Right-click the date in the jQuery UI

Why onbeforeunload event is not firing

限于喜欢 提交于 2019-12-04 19:43:05
I tried the code on Chrome, FireFox and Safari. Still the onbeforeunload does not fire. I also tried the onunload , but it did not work. Here is the code I am experimenting with: <!doctype html> <html lang="en"> <head> <title> Output to a Page </title> <meta charset="utf-8"> <script> window.onload = init; window.onclick = clk; window.onbeforeunload = closing; function clk() { window.alert("Ouch !!"); } function closing() { console.log("function alrt WORKS !!!!"); window.alert("closing now....."); } function init() { var output = ""; for (var mms = 5; mms > 0; mms--) { if (mms >= 3) { output +=

Handling text selection event in Firefox extension (preventing user from selecting text)

跟風遠走 提交于 2019-12-04 18:57:42
I was wondering if in chrome code we have some better way to detect when the user selects/highlights something in the current page than listening for keyup / mouseup and checking window.getSelection() . Any ideas? edit: Actually, what I'm trying to do is simply preventing the user from selecting any text at all in the contentDocument. Something that accomplishes this will be fine as well. (The idea behind getting the selection event was just to preventDefault() or otherwise getSelection().removeAllRanges() ) edit2: Please note that I need not just to prevent the highlighting from showing up,

Listen for keyboard events and mouse movement outside of Electron app

倖福魔咒の 提交于 2019-12-04 17:43:16
问题 I've been getting into a few Electron projects and I am trying to figure out how you could listen for any keypresses or and track mouse movement when the app is in the background. I am using the menubar plugin so the app is still running in the background. I tried using the global-shortcut API but it looks like that is for shortcuts only and you can't register individual keystrokes. I've also looked over the API and have yet to find an event for keystrokes and mouse movements outside the app

Click Loads multiple videos using YOUTUBE Iframe

主宰稳场 提交于 2019-12-04 14:43:34
问题 I have some thumbnails below the main video container. I will like when you click on each thumbnail - the associated video loads and start playing Using the NEW YOUTUBE API IFRAME approach here Your help or direction will be appreciated PREVIEW ON JSFIDDLE HERE PREVIEW LINK UPDATED*** 回答1: See this fiddle: http://jsfiddle.net/Y9j7R/5/ Run this code on load: var a = document.getElementsByTagName("a"); //1 for(var i=0; i<a.length; i++){ //2 if(!/#ytplayer/.test(a[i].href)) continue; //3 var

Adding multiple addListener events to a Google Map form with geocoding

好久不见. 提交于 2019-12-04 14:38:31
I have created a Google Map form that lets users enter an address into a text field and geocode the entry. This then puts a marker on a map. This works fine, but I want to add an additional addListener so when the user clicks the map it will add another pin where they click. For some reason my 'click' addListener is not working. How would I have multiple add Listeners like that? I attached my current code: function initialize() { var mapOptions = { center: new google.maps.LatLng(40.7,-74.0), zoom: 13, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document

jQuery/javascript different behaviours with user click and programatically click a checkbox

放肆的年华 提交于 2019-12-04 13:17:47
A bit hard to explain, so I've set up a jsFiddle here . Basically, I have some behaviour triggered when a user clicks a checkbox. In another place I'm trying to programatically click the check box and I need to see the exact same behaviour. It doesn't work, seemingly something to do with the order of the click and determining the checked attribute. How can I get the behaviour I'm looking for without resorting to a hack? I tend to use change handler here instead (since jQuery normalizes the behavior, it doesn't require a blur ), then fire that event like this: $('span').click(function() { $('

How to check if mouse click event is simulated or is native? (non-jQuery way)

一曲冷凌霜 提交于 2019-12-04 12:57:38
With jQuery it's easy. With pure JavaScript isn't, at least it isn't easy to find out how. if (event.clientX && event.clientY) { ... } gives kind-of detection, but it's not 100% accurate. There is a way, but it's quite controversial IMHO. Try this: HTMLElement.prototype.dispatchEvent = (function(dispev) { return function(event) { // Do your stuff dispev.call(this, event); }; })(HTMLElement.prototype.dispatchEvent); With this, you're able to catch every call to dispatchEvent when a programmatically generated event is dispatched. Of course, this would slow down a bit the dispatching, but shouldn