javascript-events

Can JavaScript tell the difference between leaving through the back button or a link?

允我心安 提交于 2019-12-14 04:09:07
问题 My application has pages with several tabs that simply switch the visible content. However, the page also has links that will add tabs to the page. In addition, the application remembers (with cookies) which tab you last viewed in case the page is refreshed (strict cache settings cause refreshes even when using the back and forward buttons). My problem is that the first time you visit this set of pages, it should show the first tab (Tab A). Then, you click a link, and it adds a tab, and it

Buttons OnClick Event not firing when it causes a textboxes onChange event to fire first

房东的猫 提交于 2019-12-14 04:04:33
问题 I have a few textboxes and button to save their values on a webpage. The onchange event of the textboxes fires some js which adds the changed text to a js array. The ok button when clicked flushes this to the database via a webservice. This works fine except when the onchange event is caused by clicking the ok button. In this scenario the onchange of the textboxes still fires but the onClick event of the button does not. Any ideas? textboxes look something like <input name="ctrlJPView

'data' is null or not an object IE8

╄→гoц情女王★ 提交于 2019-12-14 03:57:34
问题 I am transmitting message from an iframe to its parent page using postMessage. This is my code. In iframe: $(".history_date").click(function(event) { window.top.postMessage($(this).text(), "*"); }); In parent page: $(function(){ window.onmessage = function(e){ if(e.data){ //do something } }; }); It works well in chrome, firefox and IE9/10, but in IE8, the error indecates 'data' is null or not an object. How to fix it? Thanks in advance. 回答1: IE8 still lacks DOM2 event attachment, still using

Is it possible to extend the EventTarget interface?

雨燕双飞 提交于 2019-12-14 03:57:07
问题 I'm looking for an answer if this is possible, or even a good idea. Usually, as a fix for IE8 and earlier versions, a workaround similar to this is used: var addEvent = function(obj, e, cb) { if(obj.attachEvent) { return obj.attachEvent('on' + e, cb); } else { obj.addEventListener(e, cb, false); return true; } } and then the programmer would always use addEvent instead of addEventListener . Is there any way or point to create an addEventListener function that would wrap around the attachEvent

How can I click on specific (x,y) coordinates on a web page? [duplicate]

江枫思渺然 提交于 2019-12-14 03:29:47
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Triggering a JavaScript click() event at specific coordinates Translated question: I'm looking for a method to programmatically click on a specific (x,y) coordinate on a web page. Original question: hi i have reviewed many codes in the internet about how to let the pointer mouse move and click but i didnot find what i need example: there is a hyper link on (X=358,Y=13) of the page and it is get different every

How to make tooltip with pure javascript (onclick show/dismiss) [closed]

北城以北 提交于 2019-12-14 03:24:30
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I need to use some JS no JQuery plugins to make a simple tooltip. When I click on image I want to display div with triangle corner bellow that image with some text inside. I google and google and didn't find anything. Simple click on image to show info and click on same image to dismiss it but can't figure out

Is the canvas empty?

谁说胖子不能爱 提交于 2019-12-14 03:19:54
问题 I'm trying to make a scratch card using canvas with JS. my question is: can I know if the user have "erased" all the canvas? I have two images one on top the other, and I managed to make the user "erase" the on-top canvas image. I want to fire up a function when the canvas is empty\completly erased. Thanks var offsetT; var offsetL; var canvas = document.createElement('canvas'); canvas.id = "canvas"; var canvasWidth = 290; var canvasheight = 269; canvas.width = canvasWidth; canvas.height =

Javascript event library 'unidentified'

孤人 提交于 2019-12-14 02:59:36
问题 I have been working on a javascript library for event handling. Here is some of the code: 01| (function(){ 02| var int, 03| Jist = function(s){ 04| return new Jist.fn.init(s); 05| }; 06| Jist.fn = Jist.prototype ={ 07| init : function(s){ 08| if(!s){ 09| return this; 10| } 11| else{ 12| this.length = 1; 13| if (typeof s === "object"){ 14| this[0] = s; 15| } 16| else if(typeof s === "string"){ 17| var obj; 18| obj = document.querySelectorAll(s); 19| this[0] = obj; 20| this.elem = this[0]; 21|

how do I add same event listener to many markers and then differentiate between the markers in the listeners in google maps api v3?

孤街浪徒 提交于 2019-12-14 02:40:30
问题 I have the same event listener for many markers in my javascript. How do I differentiate between different markers in this listener? I want to display another marker elsewhere on clicking of a particular marker. Every marker has another marker which I display on clicking on it. the event listener code google.maps.event.addListener(marker, 'click', function() { //code goes here }); more detail: I have 2 arrays markers1 and markers2 each having 10 markers. I display the 10 from markers1 on my

stopping key event bubbling in safari 4 windows

一笑奈何 提交于 2019-12-14 02:13:48
问题 In safari 4 windows, it does not seem possible to stop some key events from bubbling up to the browser in javascript. This guy got pounced on for trying to stop F5 (a dubious design goal), but the technical problem remains... how do you stop certain key events from bubbling up in Safari 4? For example, You can stop: CTRL+T CTRL+N You cannot stop: CTRL+F F5 回答1: Interesting. My tests gave the same results as yours: I couldn't find a way to prevent the default action of CTRL+F in Safari 4 in