开发者

Detaching/opening an iframe into a new window

I have an 开发者_StackOverflow社区iframe setup within a page and basically want to know whether it's possible to have a button in this iframe and when pressed, opens the iframe into a new browser window, showing the contents of the iframe.

I am planning on using either JavaScript or jQuery to achieve this. I am using IE6.


$('.button').click( function(){
    window.open($('iframe').attr('src'),'mywindow','width=400,height=200');
});


For what you need (to open the same page where this button), no matter if it's an iframe or if in the home page.

The only difference is if you want that data to open in new window, are a reflection of the same page, such as data that can be an input.

If you care about who are the same data:

$("#mybuttonOpenWin").click(function(){
   window.open(window.location.href);
});

If you are interested, you can try this code:

$("#mybuttonOpenWin").click(function(){
   var mref = window.open(window.location.href);

   (function = onReadyRef(xref){
      if(xref.window.document.readyState=="complete"){
        $(xref.window.document).find("body").html($("body").html());
      }
      else{
         onReadyRef.call(this, xref);
      }
   })(mref);
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜