onload

'onload' handler for 'script' tag in internet explorer

你。 提交于 2019-11-26 01:03:42
I've been using this function to attach onload handler to a script tag, it seems to be the recommended way over the internet. Yet, it doesn't work in internet explorer, if page is loaded already (tested in ie 8). You can see that it works in normal browsers (fires alert when script is loaded). Am I missing something? Thank you SLaks You should call jQuery.getScript , which does exactly what you're looking for. EDIT : Here is the relevant source code from jQuery: var head = document.getElementsByTagName("head")[0] || document.documentElement; var script = document.createElement("script"); if (

Trying to fire the onload event on script tag

可紊 提交于 2019-11-26 00:37:38
问题 I\'m trying to load a set of scripts in order, but the onload event isn\'t firing for me. var scripts = [ \'//cdnjs.cloudflare.com/ajax/libs/less.js/1.3.3/less.min.js\', \'//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.min.js\', MK.host+\'/templates/templates.js\' ]; function loadScripts(scripts){ var script = scripts.shift(); var el = document.createElement(\'script\'); el.src = script; el.onload = function(script){ console.log(script + \' loaded!\'); if (scripts.length

Execute write on doc: It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.

狂风中的少年 提交于 2019-11-26 00:28:57
问题 I am trying to load a certain script after page load executes, something like this: function downloadJSAtOnload(){ var element = document.createElement(\"script\"); element.src = \"scriptSrc\"; document.body.appendChild(element); } if (window.addEventListener) window.addEventListener(\"load\", downloadJSAtOnload, false); else if (window.attachEvent) window.attachEvent(\"onload\", downloadJSAtOnload); else window.onload = downloadJSAtOnload; And while this script seems to execute and download

iFrame src change event detection?

喜你入骨 提交于 2019-11-26 00:09:36
问题 Assuming I have no control over the content in the iframe, is there any way that I can detect a src change in it via the parent page? Some sort of onload maybe? My last resort is to do a 1 second interval test if the iframe src is the same as it was before, but doing this hacky solution would suck. I\'m using the jQuery library if it helps. 回答1: You may want to use the onLoad event, as in the following example: <iframe src="http://www.google.com/" onLoad="alert('Test');"></iframe> The alert

How to execute AngularJS controller function on page load?

左心房为你撑大大i 提交于 2019-11-25 23:47:57
问题 Currently I have an Angular.js page that allows searching and displays results. User clicks on a search result, then clicks back button. I want the search results to be displayed again but I can\'t work out how to trigger the search to execute. Here\'s the detail: My Angular.js page is a search page, with a search field and a search button. The user can manually type in a query and press a button and and ajax query is fired and the results are displayed. I update the URL with the search term.

How do I call a JavaScript function on page load?

天涯浪子 提交于 2019-11-25 23:46:23
问题 Traditionally, to call a JavaScript function once the page has loaded, you\'d add an onload attribute to the body containing a bit of JavaScript (usually only calling a function) <body onload=\"foo()\"> When the page has loaded, I want to run some JavaScript code to dynamically populate portions of the page with data from the server. I can\'t use the onload attribute since I\'m using JSP fragments, which have no body element I can add an attribute to. Is there any other way to call a

Invoke JSF managed bean action on page load

 ̄綄美尐妖づ 提交于 2019-11-25 23:34:58
问题 Is there a way to execute a JSF managed bean action when a page is loaded? If that\'s relevant, I\'m currently using JSF 1.2. 回答1: JSF 1.0 / 1.1 Just put the desired logic in the constructor of the request scoped bean associated with the JSF page. public Bean() { // Do your stuff here. } JSF 1.2 / 2.x Use @PostConstruct annotated method on a request or view scoped bean. It will be executed after construction and initialization/setting of all managed properties and injected dependencies.