I’m using JQuery to design an application where the user can drag elements inside of a div that automatically adds scrollbars and expands the scrollHeight/scrollWidth as needed. I need to fire off an even when the scrollHeight and scrollWidth of the container div are changed. No, don’t want to use the scroll event because 1) scroll doesn’t get fired when
Tag: javascript
Check if a key is down?
Is there a way to detect if a key is currently down in JavaScript? I know about the “keydown” event, but that’s not what I need. Some time AFTER the key is pressed, I want to be able to detect if it is still pressed down. P. S. The biggest issue seems to be that after some period of time
Using HTML tags in JavaScript strings while complying with W3C rules
Here’s my code: The W3C Markup Validator doesn’t like this. It doesn’t want HTML tags inside my JavaScript code. Here’s the error message it produces if I attempt this: character “<” is the first character of a delimiter but occurred as data How can I fix this while making sure that my page doesn’t mess up if I pass the
How to exit from setInterval
I need to exit from a running interval if the conditions are correct: Answer Use clearInterval:
How can I remove an attribute with jQuery?
I can’t seem to get removeAttr to work, I’m using the example I saw on the jQuery site. Basically onclick I add the attribute to disable a field (which works just fine) but when the user clicks again it should enable the field in question. I used alerts to make sure the else block is being fired, so I know
scrape ASIN from amazon URL using javascript
Assuming I have an Amazon product URL like so How could I scrape just the ASIN using javascript? Thanks! Answer Amazon’s detail pages can have several forms, so to be thorough you should check for them all. These are all equivalent: http://www.amazon.com/Kindle-Wireless-Reading-Display-Generation/dp/B0015T963C http://www.amazon.com/dp/B0015T963C http://www.amazon.com/gp/product/B0015T963C http://www.amazon.com/gp/product/glance/B0015T963C They always look like either this or this: This should do it:
jQuery: Possible to wait for $.get to finish loading before continuing?
The folowing script does not wait for $.get to finish loading the page before continuing with the loop: data is a JSON object Any ideas or comments will be greatly appreciated. Answer That should do it. Old docs 2021 docs
Can’t add new lines in JavaScript alert Box?
I’m generating a string in PHP and then eventually passing this string into a JavaScript alert box, my problem is I actually can’t add line breaks in my alert box. My code looks as follows I’m getting the error: Undeterminnated string literal If I remove the n from the string it works 100% but without line breaks. Answer This happens
Can we create onclick popup without Javascript in CSS?
Can we create onclick popup without Javascript in CSS? Answer No, you can’t. You have to use script to wire an event handler for onlcick. and the user agent decides whether the page should be opened in a new window or tab. If you need a new popup window with custom size you have to use window.open and you can’t
What is the recommended way to pass urls as url parameters?
Using &url=’+encodeURIComponent(url); to pass a URL from browser to server will encode the url but when it is decoded at the server, the parameters of url are interpreted as seperate parameters and not as part of the single url parameter. What is the recommended way to pass urls as url parameters ? Answer encodeURIComponent() should work. For example, produces (which