dflow Posted July 26, 2009 Share Posted July 26, 2009 i have no clue in javascript im trying to avoid the operation abort problems that arise when using the lightbox jquery files. i have read a bit and this is the solution i cam up with but the files wont load // JavaScript Document <script type="text/javascript"> function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { document.write('<object type="text/javascript" src="js/prototype.js" ></object>'); })type="text/javascript" src="js/prototype.js" }) addLoadEvent(function() { document.write('<object type=" text/javascript" src="js/scriptaculous.js?load=effects,builder" ></object>'); }) addLoadEvent(function() { document.write('<object type="text/javascript" src="js/lightbox.js" ></object>'); }) </script> Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/ Share on other sites More sharing options...
KevinM1 Posted July 26, 2009 Share Posted July 26, 2009 i have no clue in javascript im trying to avoid the operation abort problems that arise when using the lightbox jquery files. i have read a bit and this is the solution i cam up with but the files wont load // JavaScript Document <script type="text/javascript"> function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { document.write('<object type="text/javascript" src="js/prototype.js" ></object>'); })type="text/javascript" src="js/prototype.js" }) addLoadEvent(function() { document.write('<object type=" text/javascript" src="js/scriptaculous.js?load=effects,builder" ></object>'); }) addLoadEvent(function() { document.write('<object type="text/javascript" src="js/lightbox.js" ></object>'); }) </script> What is it exactly that you're trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-883469 Share on other sites More sharing options...
dflow Posted July 26, 2009 Author Share Posted July 26, 2009 im trying to load the js files when the browser finished loading the whole page there is an error in all ie up to ie7 apparently the solution is to get these files load after the browser gets to the </body> tag **the lightbox script lets you show an image gallery using jquery im trying to call the files using the onload function Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-883508 Share on other sites More sharing options...
KevinM1 Posted July 26, 2009 Share Posted July 26, 2009 im trying to load the js files when the browser finished loading the whole page there is an error in all ie up to ie7 apparently the solution is to get these files load after the browser gets to the </body> tag **the lightbox script lets you show an image gallery using jquery im trying to call the files using the onload function Why not try something like: <script type="text/javascript"> window.onload = function(){ var documentHead = document.getElementsByTagName('head')[0]; var protoScript = document.createElement('script'); var scriptaculousScript = document.createElement('script'); var lightboxScript = document.createElement('script'); protoScript.type = 'text/javascript'; protoScript.src = 'js/prototype.js'; scriptaculousScript.type = 'text/javascript'; scriptaculousScript.src = 'js/scriptaculous.js?load=effects,builder'; lightboxScript.type = 'text/javascript'; lightboxScript.src = 'js/lightbox.js'; documentHead.appendChild(protoScript); documentHead.appendChild(scriptaculousScript); documentHead.appendChild(lightboxScript); } </script> Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-883531 Share on other sites More sharing options...
haku Posted July 27, 2009 Share Posted July 27, 2009 If jquery is done properly, it won't load in any browser until it is ready to be loaded. Most people who know how to use jquery know how to do this, so you may have an entirely different problem. Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-883698 Share on other sites More sharing options...
dflow Posted July 27, 2009 Author Share Posted July 27, 2009 If jquery is done properly, it won't load in any browser until it is ready to be loaded. Most people who know how to use jquery know how to do this, so you may have an entirely different problem. the original script without the onload function works fine this is a known problem in ie apparently and their fix is to update to ie8 Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-883776 Share on other sites More sharing options...
dflow Posted July 27, 2009 Author Share Posted July 27, 2009 im trying to load the js files when the browser finished loading the whole page there is an error in all ie up to ie7 apparently the solution is to get these files load after the browser gets to the </body> tag **the lightbox script lets you show an image gallery using jquery im trying to call the files using the onload function Why not try something like: <script type="text/javascript"> window.onload = function(){ var documentHead = document.getElementsByTagName('head')[0]; var protoScript = document.createElement('script'); var scriptaculousScript = document.createElement('script'); var lightboxScript = document.createElement('script'); protoScript.type = 'text/javascript'; protoScript.src = 'js/prototype.js'; scriptaculousScript.type = 'text/javascript'; scriptaculousScript.src = 'js/scriptaculous.js?load=effects,builder'; lightboxScript.type = 'text/javascript'; lightboxScript.src = 'js/lightbox.js'; documentHead.appendChild(protoScript); documentHead.appendChild(scriptaculousScript); documentHead.appendChild(lightboxScript); } </script> it loads for ever now i placed it after the </body> tag Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-883779 Share on other sites More sharing options...
KevinM1 Posted July 27, 2009 Share Posted July 27, 2009 Don't place what I wrote after the body tag. Put it in the head, where most scripts are supposed to go. Really, if you're going to attempt using JavaScript, you should at least know where to place your scripts. Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-883827 Share on other sites More sharing options...
dflow Posted July 27, 2009 Author Share Posted July 27, 2009 Don't place what I wrote after the body tag. Put it in the head, where most scripts are supposed to go. Really, if you're going to attempt using JavaScript, you should at least know where to place your scripts. sorry i was in the former solution state of mind. it now doesn't work on firefox and ie the scripts arent loaded Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-883912 Share on other sites More sharing options...
RichardRotterdam Posted July 27, 2009 Share Posted July 27, 2009 Without reading through all that code which doesn't seem necessary at all. I see you meantion jQuery and in the script I see prototype and scriptaculous mentioned. Could it be that these just conflict? If so I suggest you just stick with either prototype.js or jQuery. If you absolutely have to use both (can't imagine why). Then take a look at jquery's noconflict mode. Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-883916 Share on other sites More sharing options...
haku Posted July 27, 2009 Share Posted July 27, 2009 Put it in the head, where most scripts are supposed to go. That's actually not correct. Scripts can go anywhere, and often it's beneficial to put them at the end of the document, or at least after the element they apply to. A very visible example of this is google analytics, which is placed as the last element in the document. Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-883928 Share on other sites More sharing options...
dflow Posted July 27, 2009 Author Share Posted July 27, 2009 this is the microsoft official fix for this problem http://support.microsoft.com/kb/927917 they are of great help creating these useless browsers Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-883997 Share on other sites More sharing options...
cpd Posted July 27, 2009 Share Posted July 27, 2009 Could you not use a <!CD[DATA thing to laod in the scripts if its firefox and load them in the header or use PHP to determine the browser type and then construct the page based on that Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-884008 Share on other sites More sharing options...
KevinM1 Posted July 27, 2009 Share Posted July 27, 2009 Put it in the head, where most scripts are supposed to go. That's actually not correct. Scripts can go anywhere, and often it's beneficial to put them at the end of the document, or at least after the element they apply to. A very visible example of this is google analytics, which is placed as the last element in the document. I'm surprised they don't just use an in-house version of $(document).ready() to do that. Still, in most cases, from what I've seen/read, convention seems to be that scripts should go in the head, to be executed after window.onload, or the previously mentioned ready() function. Quote Link to comment https://forums.phpfreaks.com/topic/167516-onload-javascript-help/#findComment-884071 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.