tags:

views:

30

answers:

2

I am opening links on a page into an IFrame. But if the user right clicks and selects open in new window that will ruin the look I want since it will not have the parent page holding it. So is there a way to open the page as i have it working now when the user clicks on the link but if they choose to open in new tab to have it load the current page all over again in the new window with the link they selected loaded into the IFrame.

Thankyou

A: 

You can change all the links to use javascript instead of direct HREFs. This will mean users can't actually 'open in new tab' but will have to click them like normal. Use an 'empty' href & an onclick event to set your iframe's location property.

<a href="javascript:void(0);" onclick="document.frames[name_of_frame].location = 'some/url.html';">Link</a>

Should work

Matt S
A: 

Try dropping the following code into the pages you're trying to open within the frameset:

if (top.location.href == self.location.href) {
    top.location.href = '/path/to/frameset/page.aspx?somethingindicatingwhichpagetoloadiniframe';
}

This will determine if a parent frame is present and if not, redirect to the frameset page in which you should preload the original page in the iframe.

Luke Bennett