tags:

views:

24

answers:

1

Hi,

I have an iframe that holds a page. Now on that page, I have an image link that allows the user to detach the same screen from within the iframe and open into a new window using window.open(url,'newWin').

My questions is, as I am opening the same window that has the image link into a another screen using window.open(url,'newWin'), the same image link appears.

Any ideas how I could go about hiding this image within the window.open window alone using jQuery. The image is within a div id="img_link"

Thanks.

+1  A: 

I hope you didn't try my original answer. Here is an updated solution that should work for you:

$(function(){
    var img = $("#img_link");
    if(window.name == "newWin"){
        img.hide();
    } else {
       img.click(function(){
          window.open(window.location, 'newWin');
       });
    }
});

Since you are loading the same page twice, the code tests if it has been given a window name. If it has, it knows its the sub window and hides the link. If not, it attaches the click event which opens the popup window.

Doug Neiner
Hi Doug, at the moment, I am using the following call: $(document).ready(function(){ $('div#img_link').click( function(){ window.open(window.location ,'newWin','scrollbars=yes, toolbar=no, menubar=no, status=no, resizable=yes'); }); }); How would I incorporate your function call above?Thanks.
tonsils
All good Doug - worked a treat.
tonsils