Jump to content

Wont Load Page During Function


KyleKJune

Recommended Posts

i had a problem with getting a function to start in browsers with the onload thing because it took to long to load the video that they where able to exit before my onload function would start.i found a fix to get my function to start before page loads

if (window.attachEvent) {window.attachEvent('onload', prankroll());}else if (window.addEventListener) {window.addEventListener('load', prankroll(), false);}else {document.addEventListener('load', prankroll(), false);}
but with this my page wont load untill my prankroll function ends.is there a way i can get it to start my function before a video on my page loads but have the page load while my function is happening because my function is a series of alerts that when done clicking threw them it takes you to a new site. because it takes you to a new page the page never loads. i need it to load while my function is occurring. anyone know if i can do this?
Link to comment
Share on other sites

so you want it to start the main page, and while it is loading with what seems be a large *.swf run a function which will show annoying pop-up alerts. Then when the main swf file has finally finished loading, go to an completely different page???that would make me close the page and go somewhere else to be honest.is it loading for autostart purpose? how big is this file? can it be compressed further? converted?

Link to comment
Share on other sites

so you want it to start the main page, and while it is loading with what seems be a large *.swf run a function which will show annoying pop-up alerts. Then when the main swf file has finally finished loading, go to an completely different page???that would make me close the page and go somewhere else to be honest.is it loading for autostart purpose? how big is this file? can it be compressed further? converted?
it worked just fine with onload in google chrome but i had to change it to start before onload in other browsers because it would take to long to load.the swf last about 2 minutes long. in google chrome the video starts and my function will go right as the video is loading. the video is set to auto play and loop. when i tried my site in other browsers onload wasnt working because the it would wait till the whole entire swf has loaded. but while it was loading it was playing just not starting my function like google chrome was. its not suppose to go to a new site when the swf finishes loading it is suppose to go to another page at the end of the the function with all the alerts.the site is suppose to be a rickroll site that starts the alerts right away instead of beforeunload like other rickroll sites have.
Link to comment
Share on other sites

When adding events with addEventListener, you can't use () after the function. You must omit them so that you're give a reference to the function rather than running it.

if (window.addEventListener) {  window.addEventListener('load', prankroll, false);} else if (window.addEventListener) {  window.attachEvent('onload', prankroll)} else {  window.onload = prankroll;}

However, this method has the exact same effect as putting an onload attribute on the <body> element.In Javascript, the setTimeout() function creates a new thread, you can try using that instead. Note that I omit the parenthesis, the code won't work if I use them:

setTimeout(prankroll,1);

Link to comment
Share on other sites

When adding events with addEventListener, you can't use () after the function. You must omit them so that you're give a reference to the function rather than running it.
if (window.addEventListener) {  window.addEventListener('load', prankroll, false);} else if (window.addEventListener) {  window.attachEvent('onload', prankroll)} else {  window.onload = prankroll;}

However, this method has the exact same effect as putting an onload attribute on the <body> element.In Javascript, the setTimeout() function creates a new thread, you can try using that instead. Note that I omit the parenthesis, the code won't work if I use them:

setTimeout(prankroll,1);

i dont know exactly what to do to fix my rick roll to work in other browsers than google chrome.heres the url to the page http://prankroll.exofire.net/rickroll.htmlto see how i want it to work use it in google chrome.(it works on mine in firefox now but not ie, dont know about the other popular browsers.)i want it to be like that but in all the other main browsers as well.could someone show me the changes i need to make in my code?
Link to comment
Share on other sites

What is the redundant starter() function for? You could refer directly to prankroll() instead (omitting the parenthesis, of course).Either way, like I said before, using event listeners would have the same result as <body onload>.Use setTimeout to create a new thread and leave the page loading:

function prankRoll() {  // Some code here}setTimeout(prankRoll,1);

Link to comment
Share on other sites

What is the redundant starter() function for? You could refer directly to prankroll() instead (omitting the parenthesis, of course).Either way, like I said before, using event listeners would have the same result as <body onload>.Use setTimeout to create a new thread and leave the page loading:
function prankRoll() {  // Some code here}setTimeout(prankRoll,1);

im a beginner in javascript.could you take my above code and show me where to put it?
Link to comment
Share on other sites

im a beginner in javascript.could you take my above code and show me where to put it?
That is supposed to substitute the code you posted above. Just get rid of all the rest of the Javascript code you have (except the prankroll function) and put the setTimeout line right below it.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...