Get DOM elements of a popup for jQuery manipulation

前端 未结 1 1684
攒了一身酷
攒了一身酷 2020-12-18 08:18

I am creating a popup as follows:

   var comet = {

        popup: null, 

        newPopup: function(windowsname, w, h){
            this.popup = window.ope         


        
相关标签:
1条回答
  • 2020-12-18 09:17

    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 讨论(0)
提交回复
热议问题