onload

Is there a way to have an onload callback after changing window.location.href?

≡放荡痞女 提交于 2019-11-26 16:52:14
问题 Essentially what I'd like to do is something to the effect of this: window.location.href = "some_location"; window.onload = function() { alert("I'm the new location and I'm loaded!"); }; Is there any way to have a callback when the window's new location is loaded? (The above code doesn't work.) 回答1: No, you cannot do it the way you want. Loading a new page closes the current document and starts loading a new document. Any code in your current document will no longer be active when the new

Is bubbling available for image load events?

帅比萌擦擦* 提交于 2019-11-26 16:41:22
问题 Can I use: window.addEventListner(); in some way. All my images have a display = 'none' . Once the image has loaded, I want to set display = 'inline' This way I can normalize what is displayed while the image is being downloaded. In this case, I can not pre-load my images. 回答1: The load / onload event does not bubble (reference, reference), so what you're asking for is not possible . You'll have to attach an event handler to each image node, or intercept the event during the capture phase, as

Javascript Image onLoad

孤人 提交于 2019-11-26 14:18:24
问题 Why does the onLoad not get triggered? function FULL_IMAGE(fimage){ document.getElementById("FULL_SRC").onLoad = function(){ offsetTop = document.getElementById("FULL_SRC").height / 2; offsetLeft = document.getElementById("FULL_SRC").width / 2; document.getElementById("FULL_SRC").style.marginTop="-"+offsetTop+"px"; document.getElementById("FULL_SRC").style.marginLeft="-"+offsetLeft+"px"; } document.getElementById("FULL_SRC").src=fimage; document.getElementById("FULL_VIEW").style.display=

iFrame onload JavaScript event

为君一笑 提交于 2019-11-26 12:28:48
问题 I have an iFrame, where I want to send a JavaScript command after loading. My current code looks like this: <iframe src=\"http://www.test.tld/\" onload=\"__doPostBack(\'ctl00$ctl00$bLogout\',\'\')\"> But with this code the command isn\'t executed. What must I change to make it work? Only Chrome and Firefox have to be supported. 回答1: Use the iFrame's .onload function of JavaScript: <iframe id="my_iframe" src="http://www.test.tld/"> <script type="text/javascript"> document.getElementById('my

google.setOnLoadCallback with jQuery $(document).ready(), is it OK to mix?

笑着哭i 提交于 2019-11-26 12:06:27
问题 I\'m using Google Ajax API and they suggest I use google.setOnLoadCallback() to do various things related to their API but I\'m using also jQuery\'s $(document).ready() to do other JS things, not related to Google API. Is it safe to mix these two approaches in one document? I did not notice any problems yet but I suppose it\'s a matter of scale. 回答1: You pretty much have to do this: google.setOnLoadCallback(function() { $(function() { // init my stuff }); }); You can't do $(document).ready()

Best practice for using window.onload

好久不见. 提交于 2019-11-26 11:46:20
I develop Joomla websites/components/modules and plugins and every so often I require the ability to use JavaScript that triggers an event when the page is loaded. Most of the time this is done using the window.onload function. My question is: Is this the best way to trigger JavaScript events on the page loading or is there a better/newer way? If this is the only way to trigger an event on the page loading, what is the best way to make sure that multiple events can be run by different scripts? Luca Matteis window.onload = function(){}; works, but as you might have noticed, it allows you to

Recall Tampermonkey script when page location changes

跟風遠走 提交于 2019-11-26 11:36:35
问题 Well, I want to know if its possible to recall a Tampermonkey script when a user changes his location (but the match is still active). For example, my scripts hooks youtube website. I need to make that the script recalls itself when I change the video, my actual script is: // ==UserScript== // @name xxx // @namespace xxx // @version 1.0 // @description xxx // @author Ikillnukes // @match https://www.youtube.com/* // @match https://youtu.be/* // @grant none // ==/UserScript== console.log(\

Getting HTML body content in WinForms WebBrowser after body onload event executes

白昼怎懂夜的黑 提交于 2019-11-26 11:35:28
问题 I have a WebBrowser control in WinForms whose URL property is set to an external webpage. I also have an event handler for the DocumentCompleted event. Inside this handler, I\'m trying to get specific elements, but wb.Document.Body seems to capture the HTML before onload is executed. {System.Windows.Forms.HtmlElement} All: {System.Windows.Forms.HtmlElementCollection} CanHaveChildren: true Children: {System.Windows.Forms.HtmlElementCollection} ClientRectangle: {X = 0 Y = 0 Width = 1200 Height

jQuery.ready() equivalent event listener on elements?

泄露秘密 提交于 2019-11-26 11:25:20
问题 I am using jQuery JavaScript library. I like the event listener ready on $(document) that fires when the DOM is set up. ( Pretty similar to .onload but without external sources ) I would find it very useful, if there was an event listener wich has a very similar behaviour to this, but fires when an element is fully loaded. (f.e.: Picture, a Div with an extremely long text content, such ) I would appreciate both jQuery or JavaScript methods. 回答1: There is no event fired when an arbitrary DOM

How to run a jquery function in Angular 2 after every component finish loading

六月ゝ 毕业季﹏ 提交于 2019-11-26 11:09:49
问题 I have tried all the life cycle hooks but can\'t get to accomplish the needed result. The result that I need is triggering a function that initialize many jquery plugins used for different elements on a single page after every single one of these elements (components) is loaded. So lets say that you have this structure. Home Page Slider Widgets Product rotators ..etc Every one of these elements has it\'s own component and all are children of the Home page parent component. And what I need