Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8409453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:54:54+00:00 2026-06-09T23:54:54+00:00

I’m currently working on a script to be placed on a 3rd-party site…in order

  • 0

I’m currently working on a script to be placed on a 3rd-party site…in order to test it I’m opening the 3rd party’s site and running the script in the browser’s console (Chrome). Some code I need to executed on window.load(), but that code isn’t being executed with this method of testing. I’m assuming it’s because the code bound by load to the window is being bound after the load event has taken place, thus never being triggered. My question has two parts:

  1. Is the reason that window.load is not being triggered in fact because it’s being added after the load event has been triggered? Or is this wrong and there is likely a problem elsewhere?

  2. How best can one simulate events triggered on load when appending javascript through the console like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:54:56+00:00Added an answer on June 9, 2026 at 11:54 pm

    if(document.readyState === "complete"){ will detect if the load is already complete.

    You could easily use an else and then put in the load event handler if it hasn’t finished loading yet. Something along the lines of:

    if(document.readyState === "complete"){
      // do stuff
    }else{
      // attach load handler
    }
    

    What I like to do is define a pageLoaded type function that I can run at a later point with my code, that way I can call it immediately if the page is already loaded, or let the load handler call it when the page load does fire. Something like:

    var pageLoaded = function(){alert("Page is ready!");}
    if(document.readyState === "complete"){
      pageLoaded()
    }else{
      // attach load handler, calls pageLoaded()
    }
    

    Of course, since you tagged your question as jQuery you could always just wrap all your code in jQuery’s handy dandy ready function shorthand:

    $(function(){
      // do stuff
    });
    

    This passes your anonymous function to jQuery where it will do something very similar if not identical to the above vanilla javascript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.