Skip to content
Advertisement

Call Javascript function from URL/address bar

Is it possible to call a javascript function from the URL? I am basically trying to leverage JS methods in a page I don’t have access to the source. Something like: http://www.example.com/mypage.aspx?javascript:printHelloWorld() I know if you put javascript:alert(“Hello World”); into the address bar it will work. I suspect the answer to this is no but, just wondered if there was

How to jump to top of browser page

I’m writing a modal popup and I need the browser to jump to the top of the screen when the open modal button is pressed. Is there a way to scroll the browser to the top using jQuery? Answer You can set the scrollTop, like this: Or if you want a little animation instead of a snap to the top:

HTML5 Video Dimensions

I’m trying to get the dimensions of a video of which I’m overlaying onto a page with JavaScript, however it is returning the dimensions of the poster image instead of the actual video as it seems it’s being calculated before the video is loaded. Answer Spec: https://html.spec.whatwg.org/multipage/embedded-content.html#the-video-element

How do I hide the address bar on iPhone?

How do I hide the address bar on iPhone? I tried two different methods so far: The scroll down one pixel trick with JavaScript on page load And the following meta tags: Also this: I am completely confused. PS: Oh, I forgot a really important thing: the web page itself does not overflow the browser window. It probably is the

Client Checking file size using HTML5?

I’m trying to ride the HTML5 wave but I’m facing a small issue. Before HTML5 we were checking the file size with flash but now the trend is to avoid using flash in web apps. Is there any way to check the file size in the client side using HTML5? Answer This works. Place it inside an event listener for

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

Advertisement