Skip to content
Advertisement

Check if ‘onload’ would have fired already?

I have a situation where I’d like to set an onload handler for a script element, but it is possible that the script element has already loaded before I do so. If it’s already loaded, I’d like to detect that and run my handler immediately. What would be a reliable way of checking a script element’s onload state after the

click() method in Firefox

The following code is throwing two alerts as expected in IE but not in Firefox. Please help. Answer Firefox only has a click() function for form elements such as buttons. However, you can call the onClick function directly; you can change the line to This works in firefox or IE (but note that it requires that the function actually exists,

Ajax: HTTP Basic Auth and authentication cookie

I want to store the HTTP basic authentication headerline in an authentication cookie, so that I don’t have to deal with the authorisation header in subsequent requests (I’m using jQuery): Whilst this seems to work for the first user who logs in, it doesn’t work for any other users within the browser session, because the subsequent authorisation headers are added

Javascript find if english alphabets only

Am trying to find some text only if it contains english letters and numbers using Javascript/jQuery. Am wondering what is the most efficient way to do this? Since there could be thousands of words, it should be as fast as possible and I don’t want to use regex. Thank you for your time. Answer A regular expression for this might

jQuery’s offset() function

I know jQuery does most when it comes to cross-browser issues. I just wanted to know if offset() method of jQuery serves the purpose of cross-browser compatibility, I mean top, left, etc properties that can be derived from it? Basically once I apply top, left, etc properties (which are derived from offset() function) to an element, I need to make

simplest way to write programs in javascript on desktop?

I’m looking for way to write Javascript programs / scripts on desktop, not inside browser. I want it to run like Python – from the command line, to be able to read files, write files etc. All solutions I find mentioned (Rhino, spidermonkey, V8) are for embedding. Has anyone done simple implementation for just writing standalone programs with full capabilities

Bitshift in javascript

I’ve got a really big number: 5799218898. And want to shift it right to 13 bits. So, windows-calculator or python gives me: 5799218898 >> 13 | 100010100100001110011111100001 >> 13 70791 | 10001010010000111 As expected. But Javascript: 5799218898 >> 13 | 100010100100001110011111100001 >> 13 183624 | 101100110101001000 I think it because of internal integer representation in javascript, but cannot find anything

onclick event in the javascript

I am very new to javascript I know that you can add an onclick=”” event to a html element… but is it possible in the javascript itself to declare that when someone clicks on x element an event is triggered? Answer Make sure that you either run this after the element already exists (scripts at the bottom), or when the

Advertisement