Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Fire javascript on infinitely loading page

udayasl

New Coder
I have a simple chat script which continuously updates an HTML page with messages.

So the HTML page is infinitely loading and never reaches </body> </html> and the browser also waits till the end (that's the normal behaviour of it to update the chat with latest messages).

Now I'm going to add javascripts to increase the font size using "A+" and "A-" buttons.

Relevant code is working when I stop the "loading" status.

I need to fire javascript while the page is in the loading status..

Can anyone help me?
 
Put the script in the head before the body:
HTML:
<html>
  <head>
    <script src="script.js"></script>
  </head>
  <body>
    <!--content here-->
  </body>
</html>

Or use ajax to update the chat, rather than keep on reloading the page
 
IMO it's not clear at all what you are doing and what you want, and the thing about changing the font size seems totally irrelevant, and confusing things even more. What about sharing some code and giving some better explanations ?
 
if you want the js execute while the page is loading you can use

JavaScript:
window.onload = function() {

    //code or function call

}


window.onload = yourFunctionName();

//in jQuery

$(document).ready(function(){
   
   
    //function or call functions
   
})
 
Last edited by a moderator:
if you want the js execute while the page is loading you can use

JavaScript:
window.onload = function() {

    //code or function call

}


window.onload = yourFunctionName();

//in jQuery

$(document).ready(function(){
  
  
    //function or call functions
  
})
Isn't this for after the page has finished loading? It wouldn't work for him, because the page never finishes loading.
 
Isn't this for after the page has finished loading? It wouldn't work for him, because the page never finishes loading.
Thats why you can use window.onload page still loading and you can fire your script, but you cant execute any code in Javascript without the element you wanna change be loaded, its will give no target error
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom