开发者

Jquery: How to window.open() with no valid href?

I have web page on which I display a lot of summary information. I would like to be able to, by clicking a right button or link, to open up a new window and display the underlying data.

For many reasons I cannot request the underlying data again from the server once the summary information page is generated

What I would like to achieve is:

  • Embed the underlying data in a hidden table in the summary page
  • On thesummary page I also provide a 'drill down' button
  • Open a new window upon a click of this button
  • Inject the content of the hidden

    table into the new windows.

What I want to learn are:

  1. What to pass to 开发者_运维问答the href parameter of the window.open(href) function? How to get a reference to the new window and inject the content?

I am using jquery 1.5.2


You should pass about:blank.
open returns a new window object; you can write to its document.

However, you should consider using a modal dialog, such as jQuery UI Dialog, instead.


I'd look at using the jQuery UI dialog widget and open a dialog rather than a new window. It would be dead simple to copy stuff from the DOM into the dialog when it opens.

 $('.drilldown-button').click( function() {
       $('<div title="Details"></div>').dialog({
           autoOpen: true,
           modal: false,
           open: function() {
              $('.hidden-details').clone()
                                  .appendTo($(this))
                                  .show();
              // maybe add some handlers, etc. 
           },
           buttons: {
              'Close': function() { $(this).dialog('destroy'); }
              // maybe other buttons for different actions
           }
       });
 });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜