onload

Exactly when does an IFRAME onload event fire?

好久不见. 提交于 2019-12-03 09:45:35
Does the IFRAME's onload event fire when the HTML has fully downloaded, or only when all dependent elements load as well? (css/js/img) The latter: <body onload= fires only when all dependent elements (css/js/img) have been loaded as well. If you want to run JavaScript code when the HTML has been loaded, do this at the end of your HTML: <script>alert('HTML loaded.')</script></body></html> Here is a relevant e-mail thread about the difference between load and ready (jQuery supports both). The above answer (using onload event) is correct, however in certain cases this seems to misbehave.

Drawing multiple images to a canvas using image.onload

牧云@^-^@ 提交于 2019-12-03 07:47:57
I am running into problems when trying to draw a large 2D array of images onto a canvas. Using a separate program, I'm taking one big image file and breaking it up smaller, uniform pieces. I'm using the 2D array to represent this "grid" of images, and ideally when I assign the src of each element in the grid, that image would be drawn to its proper point on the canvas once its ready. However, my code isn't working. var grid = new Array() /*grid is set to be a 2D array of 'totalRows' rows and 'totalCols' columns*/ /*In the following code, pieceWidth and pieceHeight are the respective height

Execute my jQuery script after dynamically inserted jQuery library has finished loading

放肆的年华 提交于 2019-12-03 03:55:31
I am dynamically inserting the jQuery library on a page via <script> tag: jq = document.createElement('script'); jq.setAttribute('src','//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'); b.appendChild(jq); Then I have some jQuery script that needs to run after the jQuery library has finished loading and is ready for use: $(f).load(function() { $(f).fadein(1000); }); How can I make it wait for jQuery to load? Specify an onload event at the to-be-inserted script tag: function onLoad() { $(f).load(function() { $(f).fadein(1000); }); } jq = document.createElement('script'); jq.onload =

.onload called multiple times from Firefox extension

和自甴很熟 提交于 2019-12-03 02:57:55
I'm developing a Firefox extension and have the following code: function initialize() { // For accessing browser window from sidebar code. var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIWebNavigation) .QueryInterface(Components.interfaces.nsIDocShellTreeItem) .rootTreeItem .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIDOMWindow); var gBrowser = mainWindow.gBrowser; gBrowser.onload = function() { alert('loaded'); }; } When I open the extension (a sidebar) and proceed

Safari <body onload> event doesn't trigger from the back button

喜你入骨 提交于 2019-12-02 22:10:12
问题 I don't seem to be able to get the body onload="..." event to fire in Safari when the page is entered via the back button. It works fine in FF and IE. Is there a Javascript or jQuery solution? Any help appreciated. 回答1: Try: window.addEventListener("pageshow", function() { alert('page shown'); }, false); For Opera browser, read this: http://samuli.hakoniemi.net/onload-issues-with-opera/ 回答2: This is well known. Safari and many other browser cache the page and when you navigate back to it,

JavaScript event window.onload not triggered

寵の児 提交于 2019-12-02 21:04:05
I've got the following code in a website: window.onload = resize; window.onresize = resize; function resize(){ heightWithoutHeader = (window.innerHeight - 85) + "px"; document.getElementById("main-table").style.height = heightWithoutHeader; document.getElementById("navigation").style.height = heightWithoutHeader; } The onresize works fine, but the onload event never fires. I've tried it in Firefox and Chrome and neither of them works. Thank you for your help and go for the reputation! ;D I think what's probably happening here is that your window.onload is being overridden later, check to make

What happens if multiple scripts set window.onload?

一笑奈何 提交于 2019-12-02 08:39:42
问题 There are a number of posts on StackOverflow and other websites regarding the problem of avoiding namespace collisions. In my scenario, I just want a method in my JavaScript to be executed after the DOM is accessible. If I do the following will it avoid namespace collisions? <script type="text/javascript">window.onload = function() { //Define my namespace var here, and execute all my code }</script> What if a script that is injected later also sets an onload function ? Will mine get

Is there any bug with document.write()?

霸气de小男生 提交于 2019-12-02 08:22:16
I had my code something like this: window.onload = function() { var x = document.createElement("INPUT"); x.setAttribute("type", "text"); x.setAttribute("value", ""); document.body.appendChild(x); } And I wanted to write something more, I added a new line. Like this: window.onload = function() { var x = document.createElement("INPUT"); x.setAttribute("type", "text"); x.setAttribute("value", ""); document.body.appendChild(x); document.write("<br>"); } And then, suddenly, my input tag disappeared. So, I wrote 'AAA'to check whether the <br> code was added or not. Like this: window.onload =

javaFX webview window.onload is fired before loadworker succeeds

久未见 提交于 2019-12-02 08:12:47
I use a JavaFX webview in my application. With the following code I set a member after the page has been loaded webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() { @Override public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) { if (newState == Worker.State.SUCCEEDED) { JSObject window = (JSObject) webEngine.executeScript("window"); window.setMember("mymember", new JavaScriptBridge(this)); } } }); Now in javascript I can invoke mymember.doSomething() e.g. called when I press the button and it's executed successfully, but

Detect when images added to DOM have been loaded

ぐ巨炮叔叔 提交于 2019-12-02 08:09:35
Say, user opens a page, clicks on a button, and popup with images appears. How do I detect when all of the images have been loaded? I can't use window.onload here, since the page had already been loaded with all the assets. To make it clear, I want to find out final extents of the popup. Popup is added to DOM like so: var popup = document.createElement('div'); popup.innerHTML = '...'; document.body.appendChild(popup); Simply: var image = document.getElementById('image'); image.onload = function () { alert ("The image has loaded!"); }; setTimeout(function(){ image.src = "http://lorempixel.com