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 827233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:32:31+00:00 2026-05-15T03:32:31+00:00

When I try to call Test function I get an error. How to fix

  • 0

When I try to call “Test” function I get an error.
How to fix that? (no jquery!)

Browser:firefox
error:

TypeError: this.Test is not a function

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Untitled Document</title>
        <script type="text/javascript">



            MyClass = function(){
            }

            MyClass.prototype = {

                Init: function(){
                    var txt = document.getElementById("text");

                    if (txt.addEventListener) {
                        txt.addEventListener("keyup", this.Foo, true)
                    }


                },

                Foo: function(){
                    this.Test();
                },

                Test: function(){
                    alert('OK');
                }


            }
            window.onload = function(){
                obj = new MyClass;
                obj.Init();
            }
        </script>
    </head>
    <body>
    <textarea id="text" rows="10">
    </textarea>
    </div>
</body>
  • 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-05-15T03:32:31+00:00Added an answer on May 15, 2026 at 3:32 am

    It’s because you reference this.Foo as the event, what actually happens is that it copies that function out of the object scope, ergo this does not exist. What most people do is use an anonymous function / wrapper around the event.

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

Sidebar

Related Questions

when I try to call paper.queue(fx).length I get object not supported error. May i
whenever I try to call my ejb from a client, I get this error
When I try to call this simple function in a CFC, with the proper
When I try to call any GL15 function in lwjgl I get A NullPointerException.
Has anyone seen this error when trying to call an external C function from
I try to call a function which checks a rule and if the rule
I try to call a function which passed as function pointer with no argument,
If I try to call a member function of a member of the base
Every time I try to compile my code I get error: cannot convert parameter
I try to call an API. I just want use active resource so I

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.