onload

Load javascript file after button click

冷暖自知 提交于 2019-12-01 09:45:50
问题 I am trying to use a set of textboxes to define some data within my JavaScript file. So in a textbox I enter a Team name "Team name", and the javascript file uses this textbox to store the name of a team in order to print a set of tournament brackets. The javascript file is included in my <head> so it loads before I have actually entered the data in the text boxes. I have this code for a button in the html like so: script(type='text/javascript') $('#buttontest').click(function() { $('div

How to monitor an image source for fully loaded status

倖福魔咒の 提交于 2019-12-01 08:39:05
问题 I am loading a large number of images into a dynamic DIV and I am using a preloader to get the images. imageObj = new Image(); imageObj.src = imgpath + imgname; Each of these events creates a GET that I can see and monitor in Firebug. If I know the name and path of an image, can I watch the relevant XMLHttpRequest to see if the GET has completed? I do not want to rely on (or use) .onload events for this process. The pseudo would look something like this... if (imageObj.GET = 'complete') Has

How to use jQuery live() for img onload event?

坚强是说给别人听的谎言 提交于 2019-12-01 03:04:11
I want to run some code when an image is loaded. Also, I'd like to do it unobtrusively (not inline). More specifically, I want to use jQuery's live() function so it will happen for any dynamically loaded images. I've tried: <img class="content_image" alt="" src="..." /> <script> $('.content_image').live('load', function() { alert('loaded!'); }); </script> In addition to load , I've tried onload , and onLoad . When I replace with 'click' all works as expected so I know it's not some interfering bug. I haven't been able to find a list of available event types for the live() function, so for all

javascript: onload and onerror called together

折月煮酒 提交于 2019-11-30 23:06:24
I'm new to JavaScript and therefore confused for the variable scope... I'm trying to load an image, and replace it with another URL when it doesn't exist. I have to do it in pure JavaScript. Here I got 2 versions extremely alike, but they perform differently. The only thing in common is: they don't work. The 3rd version requires a refresh and doesn't work under IE. d is the object with number attribute, which has no problem. Here is what they have in common .attr("xlink:href", function (d) { var img = new Image(); Here the Version 1: Both onload and onerror are called. However d receives the

iframe onload in IE7/8 with Javascript

人走茶凉 提交于 2019-11-30 20:27:17
I have an iframe loading into a parent page. The iframe contains a sequence of forms, and I'd like to take action on the parent page every time the iframe content in reloaded (ie, after a form is submitted in the iframe content). The current code is located on the parent page and works in all the big players except IE (I'm only concerned with IE 7 & 8). var iframe = document.getElementById('theiframe'); function refresh( ) { alert('foo'); } if (iframe.attachEvent) iframe.attachEvent('onload', refresh); else iframe.onload = refresh; What am I missing that would prevent this from being effective

How to run code after changing the URL via window.location?

廉价感情. 提交于 2019-11-30 09:50:40
问题 I'm doing this but it doesn't work: window.addEventListener("load", function load(event){ alert('hola'); },false); window.location.assign("about:blank"); It's a Greasemonkey script. The new location is loaded but the alert is never shown. 回答1: Once you change the window.location , the current instance of your Greasemonkey script is purged. To "run code" after the location change, you need to set the script to trigger on the new page ( about:blank in this case), and then use a flag to signal

Want to call a function if iframe doesn't load or load's?

心已入冬 提交于 2019-11-30 09:31:17
I have a iframe in my page. If the iframe doesn't load, want it to alert the message " pdf not found " and if the iframe does load, it should alert " pdf opened ". Does anyone know how to achieve that? So, the idea is to use an Ajax-request to "test" the URL. Ajax-requests enable you to bind "success" and "error" handlers - unlike <iframe> elements which only provide a "load" handler. Of course, Ajax-requests are restricted by the Same Origin Policy (unless the web-server enables CORS), but you stated that the PDF is on the same domain, so there shouldn't be any issues. Also, you stated that

Can I call $(document).ready() to re-activate all on load event handlers?

爱⌒轻易说出口 提交于 2019-11-30 07:02:50
问题 Does anyone happen to know IF and HOW I could re-call all on-load event handlers? I'm referencing some .js files that I DON'T have control over, and these .js libraries do their initialization in $(document).ready(), and unfortunately don't provide any easy function to re-initialize. I'm currently trying to replace a large div block with content from an ajax call, and so I have to re-initialize the external libraries. So, it would be nice just to call $(document).ready() in order to re

iframe onload in IE7/8 with Javascript

别等时光非礼了梦想. 提交于 2019-11-30 04:49:34
问题 I have an iframe loading into a parent page. The iframe contains a sequence of forms, and I'd like to take action on the parent page every time the iframe content in reloaded (ie, after a form is submitted in the iframe content). The current code is located on the parent page and works in all the big players except IE (I'm only concerned with IE 7 & 8). var iframe = document.getElementById('theiframe'); function refresh( ) { alert('foo'); } if (iframe.attachEvent) iframe.attachEvent('onload',

hide iPhone address bar with 100% height

女生的网名这么多〃 提交于 2019-11-30 02:22:07
Many posts on this, but not quite for my situation. My page has flexible dimensions set to 100% width and 100% height, so the typical on-load scroll function isn't working. Any thoughts or other solutions? Thanks! CSS: * { margin:0; padding:0; } html, body { width:100%; height:100%; min-width:960px; overflow:hidden; } Javascript: /mobile/i.test(navigator.userAgent) && !pageYOffset && !location.hash && setTimeout(function () { window.scrollTo(0, 1); }, 1000);​ This solution from Nate Smith helped me: How to Hide the Address Bar in a Full Screen Iphone or Android Web App . Here's the essential