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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:12:18+00:00 2026-05-22T01:12:18+00:00

I am creating a popup as follows: var comet = { popup: null, newPopup:

  • 0

I am creating a popup as follows:

   var comet = {

        popup: null, 

        newPopup: function(windowsname, w, h){
            this.popup = window.open(windowsname, windowsname, 'width=' + w + ',height=' + h);
            var self = comet;
            var logOut= null;
            $(this.popup.document).ready(function(){
                logOut = self.popup.document.getElementById('logout');
                console.log(logOut);
                $(logOut).live('click', function(){
                    alert('HELLO');
                    return false;
                })
            })
        },

        some_function: function(){
             //calling it here:
             this.newPopup('index.php',1120,550);
        }
    }

The logOut sometimes (usually on the 1st window open) returns null. Also, the click handler never goes through and the original click handler operates.

How do I overwrite the real click handler of the popup?
Both pages are on my site, so there should be no cross site issues..

Here is a fiddle that shows a little of what I am trying to do: http://jsfiddle.net/maniator/K2B3q/

  • 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-22T01:12:19+00:00Added an answer on May 22, 2026 at 1:12 am

    Tested and working in Firefox 4 and Chrome 11. Check it out.

    $(function()
    {
        var comet =
        {
            popup: null,  
            newPopup: function(url, w, h)
            {
                this.popup = window.open(url, url, 'width=' + w + ',height=' + h);
                var self = this;
    
                this.popup.onload = function ()
                {
                  var doc = this.document,
                      script = doc.createElement('script');
                  script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js';
                  script.onload = function ()
                  {
                      function setup()
                      {
                          $('#logout').click(function () { alert('It worked!'); });
                      }
    
                      script = doc.createElement('script');
                      script.textContent = "(" + setup.toString() + ")();";
                      doc.body.appendChild(script);
                  };
    
                  doc.head.appendChild(script);
                };
            },
    
            foo: function()
            {
                this.newPopup('http://jsbin.com/amuza3/2', 600, 400);
            }
        };
    
        $('#clickme').click(function ()
        {
            comet.foo();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating popup windows using window.open and setting the height and width of
I'm creating a popup window with no URL source using window.open(). I don't give
Creating a popup window from main page with window.open, the child/popup page uses the
I'm creating a non-intrusive popup window to notify the user when processing a time-consuming
I read this article regarding creating popup notes with javascript and css The problem
I'm creating a popup window in a listactivity in the event onListItemClick. LayoutInflater inflater
I'm creating HTML (popup window), EXCEL and PDF report and would like to show
I have succeed creating a popup using this code in c# and wpf <Popup
I am creating modal popup canvas window in a parent page. When I close
I am creating a popup dialog using microsoft's WPF. The thing is that this

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.