Skip to content
Advertisement

Tag: javascript

Suppress JavaScript undefined errors?

I have written a script that checks a set of radiobuttons to be checked. But due to different possibilities different radiobuttons will show. Is there a way to suppress JavaScript errors when it pops undefined/getElementById is null? Something like the @-char does in PHP? Update: A bit more background info. I’ve made a website where users can submit images and

Secure random numbers in javascript?

How do I generate cryptographically secure random numbers in javascript? Answer You can for instance use mouse movement as seed for random numbers, read out time and mouse position whenever the onmousemove event happens, feed that data to a whitening function and you will have some first class random at hand. Though do make sure that user has moved the

Keep the selection in a textarea

Can I prevent the loss of selection in the “onblur” event? Answer I don’t think that’s a good idea. A user with mouse in his/her hand can click anywhere on the page. If you get him/her back into the textarea, it won’t be following the principles of web accessibility.

How to declare an array in JS (like I’d do it in PHP)?

Hey, Im trying to make a nested array in JS Chrome’s debugger tells me the ), at the end of the first nested array is an “Unexpected Token” Answer From your code it looks like you’re trying to use PHP-style arrays in JavaScript. JavaScript arrays don’t work like PHP arrays. Here’s something that’s more likely to work: To explain a

Advertisement