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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:04:34+00:00 2026-06-01T00:04:34+00:00

the javascript:alert code that is being dynamically created ONLY works if I use the

  • 0

the javascript:alert code that is being dynamically created ONLY works if I use the global object reference, gvo_Z.

But I would prefer to use either this (or a proxy to it such as lvo_this).

<div id = "target_div" ></div>   

<script language="javascript" type="text/javascript">
  function c_A( ) 
    { this.om_A = function()
        { return "got it" ;
        } ;
    } ;

  function c_Z( ) 
    { this.pvo_A = new c_A() ;

      this.om_Z = function()
        { 
          var lvo_this = this ;

          var lvs_html = "<div onmousedown='javascript:alert( gvo_Z.pvo_A.om_A() );' >press me ... WORKS ... uses global reference</div>" ;
          lvs_html += "<div onmousedown='javascript:alert( lvo_this.pvo_A.om_A() );' >press me ... does NOT work ... uses THIS reference</div>" ;
          document.getElementById( "target_div" ).innerHTML = lvs_html ;
        } ;
    } ;

  var gvo_Z = new c_Z( ) ;
  gvo_Z.om_Z() ;
</script>
  • 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-01T00:04:35+00:00Added an answer on June 1, 2026 at 12:04 am

    add a function to your created element.
    you can create your element with a name tag like this

    <div id = "target_div" ></div>   
    
    <script language="javascript" type="text/javascript">
      function c_A( ) 
        { this.pvs_test = "test" ;
        } ;
    
      function c_Z( ) 
        { this.pvo_A = new c_A() ;
    
          this.om_Z = function()
        { 
          var lvo_this = this ;
    
    
          var lvs_html = "<div name='yourdiv'>press me ... does NOT work ... uses THIS reference</div>" ;
          document.getElementById( "target_div" ).innerHTML = lvs_html ;
    document.getElementsByName( "yourdiv" )[0].onclick = function() {
    alert(lvo_this.pvo_A.pvs_test);
    };
        } ;
        } ;
    
      var gvo_Z = new c_Z( ) ;
      gvo_Z.om_Z() ;
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sometimes i use debug code to alert something in javascript (for example, matching something
I have a form field (a series of checkboxes) that's being created dynamically from
I have a JavaScript function code where I want to alert. function msgalert(x,y) {
I have a JavaScript function code where I want to alert. function msg(x,y) {
Can anyone explain why the alert() in the following JavaScript code is firing? It
I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
I'm wondering if using the following Javascript code is reliable: if (!document.cookie) { alert('Cookies
I've got the following code: <code><html> <body><br> <script type=text/javascript src=http://code.jquery.com/jquery-1.4.2.min.js /> <script type=text/javascript> alert(debug);
Sometimes JavaScript doesn't make sense to me, consider the following code that generates a
Is there a sequence of characters that can be used after malformed javascript code,

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.