Just wondering if its possible to get the x/y location of the mouse from the onload event of the document (before any mousemove events)? Answer short answer: no long answer: yes. the onload event doesn’t provide info on the mouse position, however you can set a variable when onload has fired, and use the onmousemove event on the document to
Tag: javascript
browser back acts on nested iframe before the page itself – is there a way to avoid it?
I have a page with dynamic data loaded by some ajax and lots of javascript. the page contains a list from which the user can choose and each selected value loads new data to the page. One of these data items is a url provided to an iframe. I use jQuery BBQ: Back Button & Query Library to simulate the
How to detect the screen resolution with JavaScript?
Is there a way that works for all browsers? Answer original answer Yes. update 2017-11-10 From Tsunamis in the comments: To get the native resolution of i.e. a mobile device you have to multiply with the device pixel ratio: window.screen.width * window.devicePixelRatio and window.screen.height * window.devicePixelRatio. This will also work on desktops, which will have a ratio of 1. And
How to block users from closing a window in Javascript?
Is it possible to block users from closing the window using the exit button [X]? I am actually providing a close button in the page for the users to close the window.Basically what I’m trying to do is to force the users to fill the form and submit it. I don’t want them to close the window till they have
When loading an html page via ajax, will script tags be loaded?
When you load an html document using AJAX, what does it do with the nodes inside the HEAD tag: (script,link,style,meta,title) ignore them or load and parse them? And in the case of jquery ‘s ajax() function? Answer When you call the jQuery.ajax() method, you can specify the dataType property, which describes what kind of data you are expecting from the
Best way to add DOM elements with jQuery
So I’ve seen three ways to add html/DOM elements to a page. I’m curious what the pros and cons are for each of them. 1 – Traditional JavaScript I believe the straight JS way to do it is by constructing each element, setting attributes, and then appending them. Example: 2 – Appending a string of html via jQuery I’ve noticed
JavaScript inline events syntax
Is there any reason to use one of the following more than the others: And please do not spend your valuable time to tell me to use jQuery or attachEvent/addEventListener. It’s not really the objective of my question. Answer There’s no difference at all between the first two, in this specific situation the semicolon is optional. The third one will
How to run Browser command using jQuery / Javascript?
I have one page in HTML , there are two buttons , save and print. When user click on the Print it should print the page and When user click on the Save page it should Open Save as… Box for that page. Javascript/jQuery solution preferred. Answer For printing you can use window.print(). There is no standard way to trigger
Write a truly inclusive random method for javascript
Javascript’s MATH object has a random method that returns from the set [0,1) 0 inclusive, 1 exclusive. Is there a way to return a truly random method that includes 1. e.g. While this always returns a number from the set [0,1] it is not truly random. Answer To put it bluntly, what you’re trying to do doesn’t make sense. Remember
How to get info from another website from my HTML page?
What is needed is as follows: I have an HTML webpage and I need to access another website and get something from its source code. I want to run something like to get what I need from the link and use it! However, I am using Jetpack slide bar. Does it have to do anything with HTTP requests? Answer I