I want to overlay a div over the viewport when the user drags a file onto the window. However, I’m having trouble with the event propagation. When I set the overlay to display: block it appears to fire off a dragleave event and then another dragenter and then another dragleave again, so it’s alway…
Tag: javascript
Select box truncating text when body font size changed via javascript on document ready in IE 9
IE 9 is behaving quite strangely for me. I’ve got a page font-size changing control that saves the users setting and then in the document ready sets the body font-size to that size. It works fine, the issue is, when a page with dropdowns loads, in IE 9, sometimes the text is cut off. I’ve simplifi…
Chrome extension to read HTTP response
I have this Chrome extension that modifies the header of requests before sending them. I now would like to be able, within the same extension, to check the header of the response. I searched throughout the Chrome Extension APIs but I couldn’t find anything of interest. This is the code I use for modifyi…
How to select an input element by value using javascript?
I’ve seen it’s jquery equivalent: But how do you select it using pure javascript (no jQuery). Thanks for all the responses so far but I’m sure if it is working correctly, I need to change the value of the input into something else. I though I could do this by But it appears to be not that ea…
Uncaught TypeError: Illegal invocation in JavaScript
I’m creating a lambda function that executes a second function with a concrete params. This code works in Firefox but not in Chrome, its inspector shows a weird error, Uncaught TypeError: Illegal invocation. What’s wrong with my code? Answer The console’s log function expects this to refer t…
Check image width and height before upload with Javascript
I have a JPS with a form in which a user can put an image: I have written this js: which works fine to check file type and size. Now I want to check image width and height but I cannot do it. I have tried with target.files[0].width but I get undefined. With other ways I get 0. Any suggestions?
Avoid change of a select input
Is there a way of not letting users change a select input?. I have a form with an already selected option, and I want to aware users that they are doing that and I was trying to do this. I have a select with id=users: One of the problems I have is that it only happens if I click on
Buttons that change units of measurement dynamically on page
I am trying to implement a JavaScript function that will modify the result values that are outputted into a field. Examples of results output to a field are kilobytes , and British pounds. However I have included buttons in my form which will I will want to use to modify the results to make them in Gigabytes,…
What does [object Object] mean? (JavaScript)
One of my alerts is giving the following result: What does this mean exactly? (This was an alert of some jQuery object.) Answer It means you are alerting an instance of an object. When alerting the object, toString() is called on the object, and the default implementation returns [object Object]. If you want …
What JavaScript syntax highlighter does GitHub use?
What syntax highlighter is GitHub using on their site to display the code when you click on the file names? Answer As this help page of GitHub.com says, they’re using the Linguist library, which is written in Ruby. Linguist’s highlighters for each language are within vendor/grammars. And a list of supported l…