dom-events

Reliably detect if a user is using a mouse on a webpage?

梦想的初衷 提交于 2019-12-11 03:43:49
问题 On our page we have some iframes in a long horizontally-scrolling <div> . If the user is using a mouse they can scroll with the scrollbars and we would like them to be able to select text within the iframes. If they are using touch only however, the scrollbars are a hassle and I would like to overlay a transparent element over the whole thing to give them the ability to scroll easily by dragging, this of course sacrifices the select-text feature but makes sense in that scenario. Which gets me

Is there a way to mitigate downloading of resources (images/css and js files) with Javascript?

谁说我不能喝 提交于 2019-12-11 03:37:03
问题 I have a html page on my localhost - get_description.html . The snippet below is part of the code: <input type="text" id="url"/> <button id="get_description_button">Get description</button> <iframe id="description_container" src="#"/> When the button is clicked the src of the iframe is set to the url entered in the textbox. The pages fetched this way are very big with lots of linked files. What I am interested in the page is a block of text contained in a <div id="description"> element. Is

Restrict an object to stay within another object

让人想犯罪 __ 提交于 2019-12-11 03:19:22
问题 This is related to SVG, I have a large SVG object made of paths which stays static. With a press of a button, I can create another SVG object inside the larger object. The second object can be dragged with the mousedown. PROBLEM: Now I want to add a restriction so that the second object created cannot venture outside of the main object. I tried using 'mouseup' for restriction but that does not work because the restriction is applied according to the cursor point on the second object, rather

Update prototype chosen.js dynamically

社会主义新天地 提交于 2019-12-10 23:26:38
问题 I'm a new to Prototype and I can't really understand the minimalist documentation provided here http://harvesthq.github.com/chosen/ It says that to update chosen.js dynamically, we should use this snippet Event.fire($("form_field"), "liszt:updated"); What I don't understand is, which element need to be targeted on that Event.fire . Here in my case, I have a dynamic form with two select element. On which the second select element is enabled only after user choose the option on first select

onclick event - why Javascript runs it onload

。_饼干妹妹 提交于 2019-12-10 22:49:54
问题 <p id="specialp">some content</p> <script> document.getElementById('specialp').onclick=alert('clicked'); </script> I'm just starting out with Javascript, and I don't understand why the alert is executed when page loads, but not when I click that paragraph. The handler works as I expect when I put it inline, like this: <p id="specialp" onclick="alert('clicked')" >some content</p> 回答1: This is because you didnt wrap the onclick assignment as an actual function, so it attempts to assign the

Is it possible to capture the window.location.replace event?

纵然是瞬间 提交于 2019-12-10 19:51:37
问题 If I'm currently at the URL "example.com/somepage#somehash" and I invoke window.location.hash = "anotherhash" , the URL changes to "example.com/somepage#anotherhash" . This fires the window.hashashchange event. If I am currently at the URL "example.com/somepage?a=1&b=two" and I invoke window.location.replace("?one=1&two=2") , then the URL changes to "example.com/somepage?one=1&two=2" . I've read the MDN docs, and I can't find an even that this fires. Is there one? If not, is there a simple

Mouse event not being triggered on html5 canvas

*爱你&永不变心* 提交于 2019-12-10 19:18:10
问题 I would like to know if there is any special way that one would use to register events for html5 canvas elements? The following code won't raise any mouse events on my canvas elements: function MyObject() { this.init(); }; MyObject.prototype.init = function() { var canvas = document.getElementById('myCanvas'); var ctx = canvas.getContext('2d'); var anImage = new Image('image1.png'); ctx.drawImage(anImage, 0, 0, 100, 100, 0, 0, 100, 100); canvas.onmousedown = createDelegate(this, this

Getting Uncaught Reference Error:Button1_Click is not defined

落花浮王杯 提交于 2019-12-10 17:55:00
问题 Suppose I have an aspx code here: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SearchCustomer.aspx.cs" Inherits="WebApplication1.eyeofheaven.SearchCustomer" %> <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="StyleSheets/SearchCustomerStyle.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn

Dojo/on and the capture phase

☆樱花仙子☆ 提交于 2019-12-10 17:29:06
问题 Is there a way to trigger an event in the capture phase (instead of the bubbling phase) with dojo/on? 回答1: I ended up here looking for info on the predecessor of on() - dojo.connect(). For what it's worth, dojo.connect() does not appear to support event listeners for the capture phase. It works by adding the event handler to the DOM node as a field, e.g., node["mouseclick"] = ... Since you have to use addEventListener to receive events during the capture phase, my deduction is that dojo

Redirect the page and prevent the rest of the page from loading and script from execution

浪尽此生 提交于 2019-12-10 16:38:32
问题 I need to redirect page when it starts loading (e.g. the head part of the page loaded) and once it is redirected prevent/stop the rest of the page content from loading and the rest of the script from execution. If I place this code (window.location = "/other-page-url";) at the first line after opening HEAD tag and redirect page to another one, will it stop execution of next going scripts? I want to be sure that if there are, let's say, some counter script called on the second line, just after