Skip to content
Advertisement

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

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:

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

Advertisement