dom-events

Google Map Error “Uncaught TypeError: Cannot read property 'x' of undefined”

℡╲_俬逩灬. 提交于 2019-12-11 11:32:02
问题 I am working with Google map and I wrote a JS code like below and it works perfectly when a user gives location realizing permission by Browser, but when he blocks the permission, the map doesn't show anything and wen I click on its area I get the following error:\ Error: Uncaught TypeError: Cannot read property 'x' of undefined JS SCRIPT: var pos = new Object(); var marker1 = new Object(); var marker2 = new Object(); var resp; var loc; var bus_loc; function initMap() { var map = new google

Modify `target` of mouseEvent object for Event Delegation

拥有回忆 提交于 2019-12-11 11:23:48
问题 Is it possible to modify the target property of a mouseEvent? I have an event delegator function, delegator(parentSelector, childSelector, event, callback) , which is used to bind events listeners to parent dom nodes (useful when child nodes are replaced dynamically). This works very well, except in the case the the click occurs on a childNode of the childSelector. For example, an event is bound to the body , to listen for clicks on a.clickHere , which also contains a span. If the span is

Moving a Group of SVG Elements on Mouse Click

耗尽温柔 提交于 2019-12-11 10:40:15
问题 I'm trying to move a group of circles when a user clicks one of them. The group only moves once on the first click, but not afterwards. Here's the sample code I'm using: function move_circle(e) { var grp = e.target.parentNode; grp.setAttribute("transform", "translate(" + 50 + ", " + 50 + ")"); } <g onclick="move_circle(evt)"> <circle cx="150" cy="100" r="25" fill="red" /> <circle cx="170" cy="120" r="5" fill="red" /> </g> 回答1: Every time that you click a circle, the event handler is setting

click() a button named 'submit' in Javascript

落爺英雄遲暮 提交于 2019-12-11 09:46:40
问题 I have this HTML: <input type="submit" name="submit" value="Invoeren" accesskey="s" class="buttons"/> I'd like to click() it. I can not change anything on the HTML-side. When I do getElementById("submit").click() , I get this: >>> document.getElementById("submit").click(); Cannot convert 'document.getElementById("submit")' to object Any hints? 回答1: Since you can't edit the actual HTML (to add the id attribute), and you want this to be cross-browser, you could loop over all of the input

SMIL animations fail on dynamically loaded external SVG

跟風遠走 提交于 2019-12-11 09:33:43
问题 I've created a monster animated SVG file with over 3000 paths. Each path animates independently using declarative SMIL animations. It plays slowly but beautifully in all new browsers, using a little js fallback for IE9. (I'd post a link but it wouldn't clarify anything.) I developed the page using HTML5 and inline SVG. Just as I was finishing, I realized that I didn't want to force mobile browsers to choke on this huge file. So I moved the svg to an external file, and added all the xml

Catch popup window and notify user in Firefox

心已入冬 提交于 2019-12-11 07:19:36
问题 There is a web site that randomly shows up some campaign popup windows on their web site. It would be very useful if a user would be notified when a popup is shown up on that site in Firefox, etc. Can it be possible with the help of Javascript, or any add-on, etc.? 回答1: Two options. nsIWindowWatcher - https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIWindowWatcher nsiWindowMediator - https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface

FusionTablesLayer Polygon with styleId click event not firing

三世轮回 提交于 2019-12-11 06:17:03
问题 I have a fusion table that I want to use with a styleid to configure the appearance. It seems that a FusionTablesLayer with a styleid cannot have a click event attached. Here is an example of the FusionTablesLayerOptions I am using: settings: { query: { select: 'geometry', from: '<<my table id>>' }, suppressInfoWindows: true, styleId: 2 } And here is the click event that does not fire: google.maps.event.addListener(<<my FusionTablesLayer obj>>, 'click', function () { console.log('layer click'

onClick event not firing in React redux ToDoList application

戏子无情 提交于 2019-12-11 05:35:42
问题 The onClick event is not firing at all.I am able to add todos and toggle todos but when i click on Completed todos or NotCompleted todos nothing happens.Here is the complete code for the class. There is an add to do which adds the todos.then there is a toggle to do which strikes or unstrikes a todo.the problem that I am having is with the CompletedTodos and NotCompletedTodos list items. class TodoList extends Component { render() { console.log(this.props.todos) return ( <div className='todo'>

Distinguish the click event from mouse vs screenreader

别来无恙 提交于 2019-12-11 05:35:39
问题 I built a drag and drop component, and it works like a charm, but now I need to make it accessible for screen reader users. I already have the implementation of the solution done. Basically its a context menu that pops when the enter is pressed and allow to move things around. This works like a charm when navigating without the SR (screen reader), because the implementation that I made listen to KeyEvents (keypress and keydown). The problem is when using the SR (I tested with NVDA), the

print content of <iframe> which exceeds one page

ぃ、小莉子 提交于 2019-12-11 03:52:31
问题 in my react application I have an iframe which is loaded with HTML document and content of it exceeds 1 page. on pressing Ctrl+p I want to print it in several pages but the print preview only shows one page. how it should be handled to recognize that the content of iframe is more than one A4 page? the DOM in chrome devtool looks like <div class="article-container"> <iframe style="">#document /* hundreds of <p> tags */ </iframe> </div> the structure in react app is like <div className="article