javascript-events

Can one prevent Chrome causing an infinite loop when displaying alerts on the focus event, without disabling and re-enabling the event?

喜你入骨 提交于 2019-12-30 09:54:12
问题 Consider the following code. If I click in cmbMonkeys, it causes an infinite loop of alert messages in Google Chrome. My workaround for cmbPeople works fine. Does anyone know of a another way to prevent infinite loops when displaying alerts on focus or blur events, without disabling and re-enabling the event? <html> <head> <script> var eventHandler; function cmbPeople_OnFocusHandler() { alert("focus"); } function cmbPeople_CallFocusHandler(control) { eventHandler = control.onfocus; control

Triggering Raphael events externally

被刻印的时光 ゝ 提交于 2019-12-30 09:47:08
问题 My app is using Raphaël to drop a collection of objects onto a page, each with a click handler bound that uses data attached to the object when it was loaded in via JSON. That’s all working fine. I now am trying to add in some test coverage using Cucumber (yes, I know I should have built the tests in first, I will do next time). I need to trigger a click on the first object to test that that object’s associated page loads. I’ve tried finding the appropriate SVG path for that object and

Want to fire Dropdown SelectedIndexChanged Event in Javascript

ε祈祈猫儿з 提交于 2019-12-30 09:44:28
问题 I have dropdown on my page, I am changing selected value of dropdown from popup window using javascript. I have some logic in dropdown SelectedIndexChanged event, so I need to fire the SelectedIndexChanged event when dropdown selection changed from javascript. 回答1: document.getElementById('<%= yourDropdown.ClientID %>').onchange(); This should work, if you are still getting some error, you can try like this: setTimeout('__doPostBack(\'yourcontrolClientSideID\',\'\')', 0);

How to extend XMLHttpRequest object in JavaScript?

走远了吗. 提交于 2019-12-30 07:33:31
问题 I would like to extend the existing XMLHttpRequest object so that it should work with all the browsers. Now i have been trough with JS inheritance and things however before starting i would like to see good example of it. HTML5 has upload and progress events stuff which i would like to implement in inherited new object which can behave even if the feature is not supported by not introducing JS errors to client side. so i would like to achieve something like this. Class XMLHttpRequest{} Class

Google Chrome Won't Accept .contentDocument or .contentWindow!

核能气质少年 提交于 2019-12-30 07:16:09
问题 When I try my code out: Testing.html - <script language="JavaScript" type="text/javascript"> function find() { var iframeEl = document.getElementById('love'); if ( iframeEl.contentDocument ) { var form = iframeEl.contentDocument.document.getElementById('hi').getAttribute('href'); alert(form) } else if ( iframeEl.contentWindow ) { var form = iframeEl.contentWindow.document.getElementById('hi').getAttribute('href'); alert(form) } } </script> <body onload="find()"> <iframe name="lovez" src=

Bind to ready and resize at same time using jQuery .on()

那年仲夏 提交于 2019-12-30 06:23:06
问题 This works for running the same code on both ready and resize: $(document).ready(function() { $(window).resize(function() { // Stuff in here happens on ready and resize. }).resize(); // Trigger resize handlers. });//ready How would you accomplish the same result using jQuery.on() ? 回答1: on can be used to wire up the resize and ready events just like any other event. So for your case, you could create a function that has the code you want to happen for resize and ready , and then pass it to

What is the best practice to not to override other bound functions to window.onresize?

左心房为你撑大大i 提交于 2019-12-30 05:39:09
问题 How much I dig into JavaScript, I find myself asking that much. For example we have window.onresize event handler and if I say: window.onresize = resize; function resize() { console.log("resize event detected!"); } Wouldn't that kill all other functions which is connected to the same event and just log my message in console? If so I think there should be another notifier which tells me about window resize event - or a workaround maybe - without overriding other functions which are bound to

change image on scroll

空扰寡人 提交于 2019-12-30 05:31:08
问题 On my website is a fixed image. This image should be "animated", meaning that the single frames of the animation should be iterated. So the idea is to have an array of images and that every time the user scrolls, the array is iterated and the displayed image changes, thus creating an animation. I'm not that accustomed to using JS, thus I don't really know where to start. The only thing I have is the CSS: #animation { background-repeat: no-repeat; position : fixed; width: 980px; margin: 0 auto

JQuery event handler when select element is loaded

岁酱吖の 提交于 2019-12-30 05:04:05
问题 Is there an event handler to use in JQuery when a DOM select element has finished loading? This is what I want to achieve. It is working with other events except 'load'. This piece of code is loaded in the head. $(document).on('load', 'select', function(){ var currentSelectVal = $(this).val(); alert(currentSelectVal); } ); The question was badly formed earlier. I need to attach the event handler to all select elements, both present when the document is loaded and dynamically created later.

Capture text pasted into a textarea with JQuery

左心房为你撑大大i 提交于 2019-12-30 04:02:27
问题 I have to take the paste event of a text area using JQuery. I have tried the following code but it is not working... $(document).ready(function() { $('#txtcomplaint').keyup(function() { TextCounter('txtcomplaint','counterComplaint', 1000 ); }) $('#txtcomplaint').onpaste(function() { alert() //TextCounter('txtcomplaint','counterComplaint', 1000 ); }) }); 回答1: You can do something like this $("#txtcomplaint").bind('paste', function(e) { var elem = $(this); setTimeout(function() { // gets the