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

  • SEARCH
  • Home
  • 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 8324581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:07:32+00:00 2026-06-09T00:07:32+00:00

What follows is my Javascript document, that runs in $(document).ready() . The Javascript is

  • 0

What follows is my Javascript document, that runs in $(document).ready(). The Javascript is loaded from the footer of my site. For the purposes of simplification, I’ve put [...] in place of irrelevant code.

// When the document is ready, run the display scripts
$(document).ready(function() {

// Define the frame height functions
function getDocHeight(doc) {
    [...]
}
document.domain = 'mysite.com';

function resizeIframe() {setIframeHeight('date-price-book');}

function setIframeHeight(ifrm) {
    [...]
}

function AutoResize() {
    resizeIframe();
    resizeIframe();
    setTimeout("AutoResize()", 500);
}

AutoResize();

[... more Javascript code...]

When I run the page, I get the error: Uncaught ReferenceError: AutoResize() is not defined.

I can stop this error from occurring by commenting out the line AutoResize(); (final line in my example code above). But why is this error being thrown? Surely the AutoResize() function has just been defined in the lines immediately above it?

Thanks for your help!

  • 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-09T00:07:34+00:00Added an answer on June 9, 2026 at 12:07 am
    setTimeout("AutoResize()", 500);
    

    When the setTimeout above is executed, it evalutayes the string in global scope. AutoResize() is hidden inside the closure so it is not found.

    Assign a reference to the function by using the name.

    setTimeout(AutoResize, 500);
    

    other option is a closure

    setTimeout(function() { AutoResize(); }, 500);
    

    You would use the closure method if you want to send a parameter to the function.

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

Sidebar

Related Questions

My JavaScript code is as follows: $(document).keydown(function(event){ var move, inter; clearInterval(inter); inter = setInterval(move
I have a JavaScript function that is not working now that I put in
I have a jQuery Dialog which initializes hotkeys as follows: <script type=text/javascript> $(document).bind('keydown', '<%=(i+1)%>',function
I want to write a javascript function that operates as follows: Input: Youtube Video
My code is as follows: <script> $(document).ready(function() { var tagCounter=0; $(#tag-add-button).click(function () { var
I have a Javascript as follows; if (document.getElementsByClassName('someClass')) { obj = document.getElementsByClassName('someClass'); } else
<head> <script type=text/javascript> $(document).ready(function(){ $(.open_list).hide(); $(.trigger).click(function(){ $(this).toggleClass(active).next().slideToggle(800); }); }); </script> I'm doing a list
Appreciate some insight given the following code: <script type=text/javascript> $(document).ready(function() { var soapEnv =
I'm debugging a piece of Javascript that is normally used as follows: a bookmark
The code is as follows: <body> <a href="javascript:;" id="test">hello</a> </body> <script type="text/javascript"> document.getElementById("test").addEventListener("click", function

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.