dom-events

How do I capture response of form.submit

自作多情 提交于 2019-12-27 10:43:51
问题 I have the following code: <script type="text/javascript"> function SubmitForm() { form1.submit(); } function ShowResponse() { } </script> . . . <div> <a href="#" onclick="SubmitForm();">Click</a> </div> I want to capture the html response of form1.submit ? How do I do this? Can I register any callback function to form1.submit method? 回答1: You won't be able to do this easily with plain javascript. When you post a form, the form inputs are sent to the server and your page is refreshed - the

How to make HTML element resizable using pure Javascript?

故事扮演 提交于 2019-12-27 10:33:01
问题 I was wondering how we can make a HTML element like <div> or <p> tag element resizable when clicked using pure JavaScript, not the jQuery library or any other library. 回答1: I really recommend using some sort of library, but you asked for it, you get it: var p = document.querySelector('p'); // element to make resizable p.addEventListener('click', function init() { p.removeEventListener('click', init, false); p.className = p.className + ' resizable'; var resizer = document.createElement('div');

How to make HTML element resizable using pure Javascript?

烂漫一生 提交于 2019-12-27 10:32:20
问题 I was wondering how we can make a HTML element like <div> or <p> tag element resizable when clicked using pure JavaScript, not the jQuery library or any other library. 回答1: I really recommend using some sort of library, but you asked for it, you get it: var p = document.querySelector('p'); // element to make resizable p.addEventListener('click', function init() { p.removeEventListener('click', init, false); p.className = p.className + ' resizable'; var resizer = document.createElement('div');

HTML5 DragDrop dataTransfer.types not set after event.dataTransfer.setData(mimeType, angular.toJson(item)) in chrome

家住魔仙堡 提交于 2019-12-25 09:09:16
问题 I am using druska/native_js_drag_and_drop_helper.js to automate angular-drag-and-drop-lists Issue : Even after event.dataTransfer.setData(mimeType,angular.toJson(item)) dataTransfer.types is not set or probably not allowed to read in dragstart and drop event Observation : during manual drag drop dragstart event dataTransfer {dropEffect: "none", effectAllowed: "move", items: DataTransferItemList, types: Array(1), files: FileList} dropEffect:"move" effectAllowed:"move" files:FileList items

Change icon on Google maps

谁说胖子不能爱 提交于 2019-12-25 07:33:23
问题 I have been trying several options but unfortunately I'm unable to have different icons for different locations. I also tried to find out why the weather layer optional field is blank as in other applications but it did work. I would appreciate any help. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&language=en&libraries=weather"></script> <style type="text/css"> #apDiv1 { position: absolute; right: 240px; top: 5px; width: 160px; height: 39px; z-index: 1;

Stop Observing Events with JS Prototype not working with .bind(this)

て烟熏妆下的殇ゞ 提交于 2019-12-25 06:54:52
问题 I'm working on a Javascript class based on the Prototype library. This class needs to observe an event to perform a drag operation (the current drag-drop controls aren't right for this situation), but I'm having problems making it stop observing the events. Here's a sample that causes this problem: var TestClass = Class.create({ initialize: function(element) { this.element = element; Event.observe(element, 'mousedown', function() { Event.observe(window, 'mousemove', this.updateDrag.bind(this)

Dispatch CustomEvent() to prefwindow - Firefox addon

帅比萌擦擦* 提交于 2019-12-25 06:31:43
问题 Working with a Firefox addon, I wish to send a CustomEvent() to a preference window. I open the preference window using an openDialog(), and keep a reference to the opened window. After that, I try to dispatch the event, but the event is never received. var pWin = window.openDialg("chrome://myextension/path/options.xul", "name", features); var event = new pWin.CustomEvent("prefwindow-event"); pWin.dispatchEvent(event); In the prefwindow scope, I have this code in the XUL attached script :

Dispatch CustomEvent() to prefwindow - Firefox addon

∥☆過路亽.° 提交于 2019-12-25 06:30:51
问题 Working with a Firefox addon, I wish to send a CustomEvent() to a preference window. I open the preference window using an openDialog(), and keep a reference to the opened window. After that, I try to dispatch the event, but the event is never received. var pWin = window.openDialg("chrome://myextension/path/options.xul", "name", features); var event = new pWin.CustomEvent("prefwindow-event"); pWin.dispatchEvent(event); In the prefwindow scope, I have this code in the XUL attached script :

HTML5 Drag & Drop : How to remove class added in dragenter in all parent when drop event executed (so dragleave is not executed for removing it)

那年仲夏 提交于 2019-12-25 06:00:09
问题 I Have div included in another parent div that are both allowed for "drop". In the example a class named "red" is added to all droppable object in dragenter event. So if I enter the mouse durring drag in child element both child and parent will get "red" class. When I abort the drag&drop or if I leave elements during operation, the dragleave event will remove the added "red" class. The problem is when I drop the element into child there are two options : Option 1 : event.stopPropagation() is

Why does this CSS transition event not fire when two classes are added?

三世轮回 提交于 2019-12-25 03:57:16
问题 CSS .horizontalTranslate { -webkit-transition: 3s; } .secondClass { background: red; } HTML <div class='box'></div> JS var box = document.querySelector('.box'); box.addEventListener('webkitTransitionEnd', function(evt) { alert('Finished transition!'); }, false); function transitionBox() { // this works box.className = 'horizontalTranslate'; // this does not work // box.className = 'secondClass horizontalTranslate'; } setTimeout(transitionBox, 100); Why does the transition event not fire when