dom-events

Communication from an injected script to the content script with a response

为君一笑 提交于 2019-12-01 07:38:40
Following this question , communicating between an injected script and content script can be made that way: // Content script window.addEventListener("getChromeData", function(data) { // do Chrome things; }, false); // Injected script window.dispatchEvent(new CustomEvent("getChromeData", {data: 'whatever'})); I wanted to know if there is a way to make use of returned data into the injected script, using a promise or a callback mechanism? The communication back is again done with an event. You can use a one-shot listener to achieve a promise-based response. I will be passing an extra request ID

Google Maps API v3 : Passing values to Listener function(), so as to make a circle when the marker is clicked?

对着背影说爱祢 提交于 2019-12-01 07:13:49
问题 I want to form a circle around the marker when the marker is clicked! So, Listener is added to marker and the function needs to act on the circle. Here is my Code : for(var j=0;j<lat.length;j++) { var pos = new google.maps.LatLng(lat[j],lng[j]); var marker_options = {position: pos, map:map, draggable:false}; marker[j] = new google.maps.Marker(marker_options); circle_option = {strokeColor:"#FF0000",strokeOpacity:0.8,strokeWeight:2,fillColor:"#FF0000",fillOpacity:0.35,map:null,center:pos,radius

Android WebView: Handle arrow keys in JavaScript

我怕爱的太早我们不能终老 提交于 2019-12-01 06:34:22
I have a simple WebView application which I want to control with the keyboard. Is it possible to catch arrow keys in Javascript? I have tried the following code without any luck: function handleArrowKeys(evt) { console.info('key'); } document.onkeyup = handleArrowKeys; document.onkedown = handleArrowKeys; document.onkepress = handleArrowKeys; Javascript is enabled in the webview WebSettings webSettings = webview.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); Dynamic Content You should overwrite the onKeyDown method of WebView. See: http://blog

Google maps v3 open infowindow from a link outside of map

荒凉一梦 提交于 2019-12-01 04:12:50
问题 I'm trying to open the info window when a user clicks on a link from outside the map. Not sure what I'm missing here. Basically, I have a list of cities with an id for each (var ids loops over the ids). When the user clicks on that link (on click="myclick('1')" id like the infowindow for that city(1 = london etc) to open up. Any help would be appreciated. var url = "my json link"; var gmarkers = []; function initialize() { var myLatlng = new google.maps.LatLng(0, 0); var myOptions = {

focus() in Edge browser

孤街浪徒 提交于 2019-12-01 04:12:37
问题 I am using popup.focus() to focus a popup window after a button is clicked. The focus() is working fine for all the browsers except for ****EDGE**** browser. The issue I am facing is intermittent. At times I am able to view the popup window (child popup dialog box) on the browser and at times behind the browser i.e. on the desktop and I am able to identify that the popup is open by the flashing on the task bar. Any suggestion would be really appreciated. var popup = new PopupWind(url,'config'

Detect if element has stopped momentum scrolling?

谁都会走 提交于 2019-12-01 03:55:09
Is it possibile to detect if an element has stopped scrolling in Mobile Safari via Javascript? I have an element that has momentum scrolling by using -webkit-overflow-scrolling:touch , and I need to detect if the element has stopped scrolling, including after the momentum affects the scroll. Is this possible? Using the onscroll event is not working as it should within my app. dagge You can calculate a swipe velocity and try to figure out if momentum scroll will occur based on some threshold value. I've done some testing and about 0.25 pixels/ms seems to be a good value. Note: Sometimes

catch-all keyup/keydown events in iframe?

流过昼夜 提交于 2019-12-01 03:45:57
I'm working on a canvas-based game and am using window.addEventListener() to attach keyup and keydown events globally. This works in when viewing the page normally, but when embedding it as an iframe; it doesn't get the keyup and keydown events. Is there a better way I can do this? You can't, not unless the frame has focus. What you can do is make a keydown on the outer window focus the iframe, or always somehow focus the iframe, or focus the iframe by default (might be good enough, not sure what you're doing) But for the window keydown to fire on any window (frame or not) that frame needs

jQuery - Event for when an attribute of a node changes

若如初见. 提交于 2019-12-01 03:23:25
问题 I have a webpage with an external javascript library, and my own extra code. The external library can't be change. It manipulates dom elements, adds new ones, changes attributes (e.g. src on some <img> nodes, etc.). I am using jQuery. Is there any event handler that is fired when the value of an attribute changes of a node? i.e. is there anyway I can detect (in jQuery) when the src of an <img> is changed (by someone else?) 回答1: You can go for the jQuery watch plugin to detect changes in the

How to wait for a Java applet to finish loading on Safari?

你离开我真会死。 提交于 2019-12-01 02:52:29
问题 This doesn't work in Safari: <html> <body> <applet id="MyApplet" code="MyAppletClass" archive="MyApplet.jar"> <script type="text/javascript"> alert(document.getElementById('MyApplet').myMethod); </script> </body> </html> myMethod is a public method declared in MyAppletClass . When I first load the page in Safari, it shows the alert before the applet has finished loading (so the message box displays undefined ) . If I refresh the page, the applet has already been loaded and the alert displays

window.location.href doesn't redirect

本秂侑毒 提交于 2019-12-01 02:22:15
I know this is a question much discussed but I can't figure out why it does not work for me. This is my function: function ShowComments(){ alert("fired"); var movieShareId = document.getElementById('movieId'); //alert("found div" + movieShareId.textContent || movieShareId.innerText); //alert("redirect location: /comments.aspx?id=" + movieShareId.textContent || movieShareId.innerText + "/"); window.location.href = "/comments.aspx?id=" + movieShareId.textContent || movieShareId.innerText + "/"; var newLocation = window.location; //alert("full location: " + window.location); } If I have the