views:

57

answers:

2

Hi,

I have an 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.

If possible, would really appreciate any help using either javascript or jQuery on how to achieve this.

I am using IE6.

Thanks.

+3  A: 
$('.button').click( function(){
    window.open($('iframe').attr('src'),'mywindow','width=400,height=200');
});
PetersenDidIt
but you may need to use more specific selector for iframe like its id `$("#frame1")`
TheVillageIdiot
Thanks for the replies - just one question though, I am using IE6 and I actually want the window.open() to open fullscreen with top toolbar so that user can close screen. I have tried the fullscreen but I can't get the top toolbar activated - any ideas?
tonsils
A: 

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);
});
andres descalzo