Search Results

Search found 818 results on 33 pages for 'onload'.

Page 2/33 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • event listeners on plugin in document.onload events in opera

    - by gf
    I am trying to understand an issue where event-listener registration on plugins doesn't work in Opera unless i delay them. In particular, this doesn't work: document.onload = function() { plugin.addEventListener("foo", function() { alert('onFoo'); }, false); } while delaying the addEventListener() call somewhat through e.g. an alert() does: document.onload = function() { alert('onload()'); plugin.addEventListener("foo", function() { alert('onFoo'); }, false); } It seems that plugins are only loaded after document.onload. As a non-web-developer, am i missing something simple here? Or is this a known Opera problem with a common work-around?

    Read the article

  • Dynamically created iframe used to download file triggers onload with firebug but not without

    - by justkt
    EDIT: as this problem is now "solved" to the point of working, I am looking to have the information on why. For the fix, see my comment below. I have an web application which repeatedly downloads wav files dynamically (after a timeout or as instructed by the user) into an iframe in order to trigger the a default audio player to play them. The application targets only FF 2 or 3. In order to determine when the file is downloaded completely, I am hoping to use the window.onload handler for the iframe. Based on this stackoverflow.com answer I am creating a new iframe each time. As long as firebug is enabled on the browser using the application, everything works great. Without firebug, the onload never fires. The version of firebug is 1.3.1, while I've tested Firefox 2.0.0.19 and 3.0.7. Any ideas how I can get the onload from the iframe to reliably trigger when the wav file has downloaded? Or is there another way to signal the completion of the download? Here's the pertinent code: HTML (hidden's only attribute is display:none;): <div id="audioContainer" class="hidden"> </div> JavaScript (could also use jQuery, but innerHTML is faster than html() from what I've read): waitingForFile = true; // (declared at the beginning of closure) $("#loading").removeClass("hidden"); var content = "<iframe id='audioPlayer' name='audioPlayer' src='" + /path/to/file.wav + "' onload='notifyLoaded()'></iframe>"; document.getElementById("audioContainer").innerHTML = content; And the content of notifyLoaded: function notifyLoaded() { waitingForFile = false; // (declared at beginning of the closure) $("#loading").addClass("hidden"); } I have also tried creating the iframe via document.createElement, but I found the same behavior. The onload triggered each time with firebug enabled and never without it. EDIT: Fixed the information on how the iframe is being declared and added the callback function code. No, no console.log calls here.

    Read the article

  • Check if 'onload' would have fired already?

    - by thomasrutter
    Hello, I have a situation where I'd like to set an onload handler for a script element, but it is possible that the script element has already loaded before I do so. If it's already loaded, I'd like to detect that and run my handler immediately. What would be a reliable way of checking a script element's onload state after the fact? BTW I know that IE uses readyState instead of an onload event so I don't need help for that.

    Read the article

  • JS and Body(Window) Onload event

    - by Ilian
    I have a problem with onload event. My page have 4 iframes and the function from onload event is called 5 times ( one for body and 4 for iframes ). I want only 1 time ( from main body ). Try with srcElement and target property from windows.event but no result... Is there a way to stop onload when iframes load?

    Read the article

  • onLoad focus() event within jquerytools overlay effect

    - by tomcritchlow
    Hi, I'm using the overlay jquery from here: http://flowplayer.org/tools/overlay/index.html Within my overlay I have a search box like this: <div class="simple_overlay" id="asearch"> <div id="searchbox"> <form id="amazonsearch" style='float:left;'> <input class="title" id="amazon-terms" style="width:400px;font-size:2em;"> <button class="sexybutton sexysimple sexygreen">Search</button> </form> <div id="amazon-results"></div> </div><!--seachbox--> </div><!--Overlay--> What I want to happen is when you load the overlay the search box within the overlay gains focus so you can start typing into it. I thought that this would work: $("a[rel]").overlay({ onLoad: function() { $('#amazon-terms').focus(); } }); But that doesn't seem to do anything. I know the event is firing because this works: $("a[rel]").overlay({ onLoad: function() { alert('popup opened') } }); However, when this alert fires the overlay has not yet appeared on the screen so I wonder if that is part of the problem? According to the docs onLoad should fire "when the overlay has completely been displayed" (ref) Any help appreciated! :) Thanks Tom EDIT This code does what I want it to but I'm none the wiser as to why this works when the code above doesn't.... var triggers = $("a[rel]").overlay({ closeOnClick: false, onLoad: function() { $('input').focus(); } });

    Read the article

  • Back button causes iFrame to delay window.onLoad event

    - by JoJo
    I serve ads through an iFrame. The ad network's servers are much slower than mine, so I asyncronously load the iFrame after the window.onLoad event. Event.observe( window, 'load', function() { $('ad').writeAttribute('ad.html'); } ); A problem occurs when you enter the site via the browser's back button. Unexpectedly, the ad iFrame attempts to load immediately, delaying window.onLoad for a few seconds. During these few seconds, the site is unusable because I do a bunch of initialization after window.onLoad. As far as I know, this only happens in Firefox. How do I prevent this blocking load?

    Read the article

  • Javascript appending onload to a popup window

    - by Hypnotic Meat
    I'm trying to append an onload event to a popup window in the following manner: var explorerWindow = window.open(PARAMS...); explorerWindow.onload = function() {window.opener.unlockObj(id);} The idea is to make the button that generates the popup window readonly, making it usable again once the popup window has loaded all of its contents. However, the event doesn't seem to be firing at all. I even changed it to the following and got nothing: explorerWindow.onload = function() {alert("bloop");} Is there something terribly wrong with my syntax or am I missing something else entirely? Also, I'm using JQuery if there are any appropriate gems there that will help in this situation. I tried the following with similar results, but I'm not so sure I got the call right: $(explorerWindow).load(function() {alert("bloop");}); Any help is greatly appreciated.

    Read the article

  • trying to understand some codes related to window.onload in js

    - by user2507818
    <body> <script language="javascript"> window.tdiff = []; fred = function(a,b){return a-b;}; window.onload = function(e){ console.log("window.onload", e, Date.now() ,window.tdiff, (window.tdiff[1] = Date.now()) && window.tdiff.reduce(fred) ); } </script> </body> Above code is taken from a site. In firefox-console, it shows: window.onload load 1372646227664 [undefined, 1372646227664] 1372646227664 Question: For window.tdiff->[undefined, 1372646227664], why not:[], because when runs to code:window.tdiff, it is still an empty array? For window.tdiff.reduce(fred)->1372646227664, window.tdiff = [undefined, 1372646227664], undefined - 1372646227664, should be NaN, why it shows 1372646227664?

    Read the article

  • whats the substitute for a body onload?

    - by Jason94
    i have a javascript that i need to load at the body, but since im trying to build something flexible i really want it to function on a onLoad on a divtag. But thats not going to happen as i understand it as onLoad does not work on a divtag. is there another way i can load/start a function within a divtag?

    Read the article

  • how to use window.onload?

    - by Patrick
    I'm refactoring a website using MVC. What was a set of huge pages with javascript, php, html etc etc is becoming a series of controllers and views. I'm trying to do it in a modular way so views are split in 'modules' that I can reuse in other pages when needed eg. "view/searchform displays only one div with the searchform "view/display_events displays a list of events and so on. One of the old pages was supposed to load a google map with a marker on it. Amongst the rest of the code, I can identify the relevant bits as follows <head> <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=blablabla" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); var point = new GLatLng(<?php echo ($info->lat && $info->lng) ? $info->lat .",". $info->lng : "51.502759,-0.126171"; ?>); map.setCenter(new GLatLng(<?php echo ($info->lat && $info->lng) ? $info->lat .",". $info->lng : "51.502759,-0.126171"; ?>), 15); map.addControl(new GLargeMapControl()); map.addControl(new GScaleControl()); map.addOverlay(new GMarker(point)); var marker = createMarker(point,GIcon(),"CIAO"); map.addOverlay(marker); } } //]]> </script> </head> ...then <body onload="load()" onunload="GUnload()"> ...and finally this div where the map should be displayed <div id="map" style="width: 440px; height: 300px"> </div> Don't know much about js, but my understanding is that a) I have to include the scripts in the view module I'm writing (directly in the HTML? I would prefer to load a separate script) b) I have to trigger that function using the equivalent of body onload... (obviously there's no body tag in my view. In my ignorance I've tried div onload=.... but didn't seem to be working :) What do you suggest I do? I've read about window.onload but don't know what's the correct syntax for that. please keep in mind that other parts of the page include other js functions (eg, google adsense) that are called after the footer.

    Read the article

  • Detecting the onload event of a window opened with window.open

    - by Chris T
    window.popup = window.open($(this).attr('href'), 'Ad', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); $(window.popup).onload = function() { alert("Popup has loaded a page"); }; This doesn't work in any browser I've tried it with (IE, Firefox, Chrome). How can I detect when a page is loaded in the window (like an iframe onload)?

    Read the article

  • Google Maps API 3 How to call initialize without putting it in Body onload

    - by Bex
    Hi I am using the google maps API and have copied the examples and have ended up with a function called "initialize" that is called from the body onload. I am using the maps in a few different user controls, which are placed within content place holders, so the body tag is in the master page. Is there a way of calling initialize directly in the usercontrol rather than having to place an onload on the masterpage? Ideally I want my user control to be a stand alone control that I can just slot into pages without trying to access the master page body onload. I have tried calling the Initialize function from my page load of the user control (by adding a start up script), but the map doesn't appear. Any suggestions? My code: <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">/script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> var map; var geocoder; function initialize() { geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(51.8052184317649, -4.965819906250006); var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); $.ajax({ type: "POST", url: "/GoogleMapsService.asmx/GetPointers", contentType: "application/json; charset=utf-8", dataType: "json", beforeSend: function () { $(".loadingData").html("<p>Loading data..</p>"); }, complete: function () { $(".loadingData").html(""); }, cache: true, success: mapPoints, error: onError }); } function onError(xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(xhr.responseText); } function mapPoints(response) { if (response.d != null) { if (response.d.length > 0) { for (var i = 0; i < response.d.length; i++) { plotOnMap(response.d[i].Id, response.d[i].Name, response.d[i].Lat, response.d[i].Long, response.d[i].ShortDesc) } } } } and on my test master page: <body onload="initialize()"> <form runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager> <asp:ContentPlaceHolder ID="MainContent" runat="server"> </asp:ContentPlaceHolder> </form> </body>

    Read the article

  • img onload doesn't work well in IE7

    - by rmeador
    I have an img tag in my webapp that uses the onload handler to resize the image: <img onLoad="SizeImage(this);" src="foo" > This works fine in Firefox 3, but fails in IE7 because the image object being passed to the SizeImage() function has a width and height of 0 for some reason -- maybe IE calls the function before it finishes loading?. In researching this, I have discovered that other people have had this same problem with IE. I have also discovered that this isn't valid HTML 4. This is our doctype, so I don't know if it's valid or not: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Is there a reasonable solution for resizing an image as it is loaded, preferably one that is standards-compliant? The image is being used for the user to upload a photo of themselves, which can be nearly any size, and we want to display it at a maximum of 150x150. If your solution is to resize the image server-side on upload, I know that is the correct solution, but I am forbidden from implementing it :( It must be done client side, and it must be done on display. Thanks. Edit: Due to the structure of our app, it is impractical (bordering on impossible) to run this script in the document's onload. I can only reasonably edit the image tag and the code near it (for instance I could add a <script> right below it). Also, we already have Prototype and EXT JS libraries... management would prefer to not have to add another (some answers have suggested jQuery). If this can be solved using those frameworks, that would be great. Edit 2: Unfortunately, we must support Firefox 3, IE 6 and IE 7. It is desirable to support all Webkit-based browsers as well, but as our site doesn't currently support them, we can tolerate solutions that only work in the Big 3.

    Read the article

  • Determine image src in onload and onerror event handlers in IE

    - by Bill
    How can I determine the image src of the image that triggered the event in the onload and onerror event handlers in IE? This example code I threw together: <script language="javascript" type="text/javascript" src="jquery.js"></script> <script language="javascript" type="text/javascript"> function loadImages() { var goodImage = new Image(); var missingImage = new Image(); $(goodImage).bind('load', function(event){ $("#log").append( $(event.target).attr('src') + ' WAS FOUND <br>'); }); $(missingImage).bind('load', function(event){ $("#log").append( $(event.target).attr('src') + ' WAS FOUND <br>' ); }); $(goodImage).bind('error', function(event){ $("#log").append( $(event.target).attr('src') + ' IS MISSING <br>'); }); $(missingImage).bind('error', function(event){ $("#log").append( $(event.target).attr('src') + ' IS MISSING <br>'); }); goodImage.src = 'GOOD-IMAGE.GIF'; // this image exists missingImage.src = 'MISSING-IMAGE.GIF'; // this image doesn't exist } </script> </head> <body onload="loadImages();"> <div id="log"></div> works in FF but in IE8 it prints out undefined for the $(event.target).attr('src') part. I thought jQuery was supposed to normalize the event object for IE so that it acted like other browsers? I've tried a number of permutations but haven't been able to get anything to work in IE8. Anyway if anyone has a suggestion on how to figure out the image src in the onload and onerror event handlers that works in IE I would really appreciate it. Or even how to figure out after the images have loaded which have loaded and which haven't (but not graphically - I need to generate an array containing the filenames of the images that didn't load). Thanks!

    Read the article

  • function onload not working for IE7 and 8

    - by Ankita
    Hi All, My onload function is not working for IE7 and 8: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript"> function onload() { alert("Working properly") } </script> </head> <body> </body> </html> The alert doesn't happen if I try to access it with IE7 or 8 but it's working properly in Mozilla. Can anyone suggest something which works for both IE and Mozilla?

    Read the article

  • window.onload DOM loading in popup, browser compatibility

    - by user1477508
    I have HTML popup window and i want add text after opening window with spec. function: var win = window.open('private.php', data.sender_id , 'width=300,height=400'); win.window.onload = function() { //function for add text //chrome and firefox fire, IE and Opera not }; This work perfectly with Chrome and Firefox, but Opera and IE9 won't working. Please tell me best way to do that with IE and Opera. I try with: $(document).ready(function(){ //function for add text }); but same thing. I found solution, but i wont know is there better solution then setTimeout??? Instead onload event i use: setTimeout(function(){ //add text },200);

    Read the article

  • Display random image when page loads without utilizing onload in the body tag

    - by Peachy
    I'm trying to create a fairly simple piece of JavaScript that displays a random image from an array each time the page loads. I need to figure out a way to get this running without adding code to the body tag. Is there a way to accomplish this without, say, an onload funtion placed in the body tag? Here's what I have that relies on the onLoad: ImageSwitch=new Array(); ImageSwitch[0]='1.jpg'; ImageSwitch[1]='2.jpg'; ImageSwitch[2]='3.jpg'; ImageSwitch[3]='4.jpg'; function swapImage() { document.getElementById("theImage").setAttribute("src", ImageSwitch[ Math.round(Math.random()*3)]) } Any alternative ideas to accomplish this? Thanks.

    Read the article

  • Periods in Javascript function definition (function window.onload(){}) [closed]

    - by nemec
    Possible Duplicate: JavaScript Function Syntax Explanation: function object.myFunction(){..} I've seen some (legacy) javascript code recently that looks like: function window.onload(){ // some code } This doesn't look like valid javascript to me since you can't have a period in an identifier, but it seems to work in IE8. I assume it's the equivalent of: window.onload = function(){} I've tried the same code in Chrome and IE9 and both of them raise syntax exceptions, so am I correct in thinking that this "feature" of IE8 is some non-standard function definition that should be replaced? The code in question is only sent to IE browsers, so that's probably why I haven't run into this issue before.

    Read the article

  • Car animations in Frogger on Javascript

    - by Mijoro Nicolas Rasoanaivo
    I have to finish a Frogger game in Javascript for my engineering school degree, but I don't know how to animate the cars. Right now I tried to manipulate the CSS, the DOM, I wrote a script with a setTimeout(), but none of them works.Can I have some help please? Here's my code and my CSS: <html> <head> <title>Image d&eacute;filante</title> <link rel="stylesheet" type="text/css" href="map_style.css"/> </head> <body onload="start()"> <canvas id="jeu" width="800" height="450"> </canvas> <img id="voiture" class="voiture" src="car.png" onload="startTimerCar()"> <img id="voiture2" class="voiture" src="car.png" onload="startTimerCar()"> <img id="voiture3" class="voiture" src="car.png" onload="startTimerCar()"> <img id="bigrig" class="bigrig" src="bigrig.png" onload="startTimerBigrig()"> <img id="bigrig2" class="bigrig" src="bigrig.png" onload="startTimerBigrig()"> <img id="bigrig3" class="bigrig" src="bigrig.png" onload="startTimerBigrig()"> <img id="hotrod" src="hotrod.png" onload="startTimerHotrod()"> <img id="hotrod2" src="hotrod.png" onload="startTimerHotrod()"> <img id="turtle" src="turtles_diving.png" onload="startTimerTurtle()"> <img id="turtle2" src="turtles_diving.png" onload="startTimerTurtle()"> <img id="turtle3" src="turtles_diving.png" onload="startTimerTurtle()"> <img id="small" src="log_small.png" onload="startTimerSmall()"> <img id="small2" src="log_small.png" onload="startTimerSmall()"> <img id="small3" src="log_small.png" onload="startTimerSmall()"> <img id="small4" src="log_small.png" onload="startTimerSmall()"> <img id="med" src="log_medium.png" onload="startTimerMedium()"> <img id="med2" src="log_medium.png" onload="startTimerMedium()"> <img id="med3" src="log_medium.png" onload="startTimerMedium()"> <script type="text/javascript"> var X = 1; var timer; function start(){ setInterval(init,10); document.onkeydown = move; var canvas = document.getElementById('jeu'); var context = canvas.getContext('2d'); var frog = document.getElementById('frog'); var posX_frog = 415; var posY_frog = 400; var voiture = [document.getElementById('voiture'),document.getElementById('voiture2'),document.getElementById('voiture3')]; var bigrig = [document.getElementById('bigrig'),document.getElementById('bigrig2'),document.getElementById('bigrig3')]; var hotrod = [document.getElementById('hotrod'),document.getElementById('hotrod2')]; var turtle = [document.getElementById('turtle'),document.getElementById('turtle2'),document.getElementById('turtle3')]; var small = [document.getElementById('small'),document.getElementById('small2'),document.getElementById('small3'),document.getElementById('small4')]; var med = [document.getElementById('med'),document.getElementById('med2'),document.getElementById('med3')]; function init() { context.fillStyle = "#AEEE00"; context.fillRect(0,0,800,50); context.fillRect(0,200,800,50); context.fillRect(0,400,800,50); context.fillStyle = "#046380"; context.fillRect(0,50,800,150); context.fillStyle = "#000000"; context.fillRect(0,250,800,150); var img= new Image(); img.src="./frog.png"; context.drawImage(img,posX_frog, posY_frog, 46, 38); } function move(event){ if (event.keyCode == 39){ if( posX_frog < 716 ){ posX_frog += 50; } } if(event.keyCode == 37){ if( posX_frog >25 ){ posX_frog -= 50; } } if (event.keyCode == 38){ if( posY_frog > 10 ){ posY_frog -= 50; } } if(event.keyCode == 40){ if( posY_frog <400 ){ posY_frog += 50; } } } } </script> </body> And my map_css: #jeu{ z-index:10; width: 800px; height: 450px; border: 2px black solid; overflow: hidden; position: relative; transition:width 2s; -moz-transition:width 2s; /* Firefox 4 */ -webkit-transition:width 2s; /* Safari and Chrome */ } #voiture{ z-index: 100; position: absolute; top: 315px; left: 48px; transition-timing-function: linear; -webkit-transition-timing-function: linear; -moz-transition-timing-function: linear; } #voiture2{ z-index: 100; position: absolute; top: 315px; left: 144px; } #voiture3{ z-index: 100; position: absolute; top: 315px; left: 240px; } #bigrig{ z-index: 100; position: absolute; top: 365px; left: 200px; } #bigrig2{ z-index: 100; position: absolute; top: 365px; left: 400px; } #bigrig3{ z-index: 100; position: absolute; top: 365px; left: 600px; } #hotrod{ z-index: 100; position: absolute; top: 265px; left: 200px; } #hotrod2{ z-index: 100; position: absolute; top: 265px; left: 500px; } #hotrod3{ z-index: 100; position: absolute; top: 265px; left: 750px; } #turtle{ z-index: 100; position: absolute; top: 175px; left: 50px; } #turtle2{ z-index: 100; position: absolute; top: 175px; left: 450px; } #turtle3{ z-index: 100; position: absolute; top: 175px; left: 250px; } #small{ z-index: 100; position: absolute; top: 125px; left: 20px; } #small2{ z-index: 100; position: absolute; top: 125px; left: 220px; } #small3{ z-index: 100; position: absolute; top: 125px; left: 420px; } #small4{ z-index: 100; position: absolute; top: 125px; left: 620px; } #med{ z-index: 100; position: absolute; top: 75px; left: 120px; } #med2{ z-index: 100; position: absolute; top: 75px; left: 320px; } #med3{ z-index: 100; position: absolute; top: 75px; left: 520px; } I had to say that I'm in the obligation to code in HTML5, CSS3, and Javascript but not jQuery, who is way more easier, I already created games in jQuery... It takes me too much time and too much code lines right here.

    Read the article

  • JQuery conflict with body onload event.

    - by Evgeny
    Strange conflict in my code. I have function that called from body onload: var someGlobalVar=new SpecialType(); function OnBodyLoad() { someGlobalVar.Bind(); } but when i include JQuery 1.4.2 to my project i have error that someGlobalVar is undefined. Why global variable now is undefined and what ways to fix it?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >