Open links of iframe in a new tab of the parent page - html

I have a website which contains an iframe to load another website. When a user is clicking a link in the iframe, the navigation is happening inside the iframe which is fine. However, when a user opens a link in a new tab (e.g. with the mouse wheel) the direct link is opened and the parent site is gone. The problem is that I need the new tab to open in the parent otherwise the page will fail over time (the parent page is for example handling authentication). Is there a possibility to achieve this? I have full control over both websites.

Related

Style a button to maintain its highlighting after leaving the page and returning

When a link is clicked and the browser redirects to another page the highlighting is maintained when revisiting the original page. This allows the user to know which links she has clicked even after they have left the page. Is it possible to apply this same functionality to a button?

browser back button causes an iframe to be navigated

I have a web-page and withing that page I am using an iFrame. this iFrame contains two buttons previous & next. On next button click I change the source of iFrame to lets say page2.html and on previous button click i change the source back to page1.html. Issue is when i click the browser back and forward buttons it causes the iFrame to navigate (depicting the functionality of those above buttons). How can I avoid this, that is on browser back button click previous page should be loaded (of browser's rather iframe's).
Thanks
I got the solution to the problem. I have to replace the url of the frame by window.location.replace(newurl).
in this case it doesn't add into browser history.

Link to navigate to an anchor point in another browser window

We've had an interesting request from a client. They'd like their users to have two windows/ tabs open (one content, one form) which the user switches between.
Parts of the content (which is large) relate to parts of the form (which is also large).
So they'd like the following:
www.example.com/content.html#info1 links to www.example.com/form.html#question1
www.example.com/content.html#info2 links to www.example.com/form.html#question2
www.example.com/content.html#info3 links to www.example.com/form.html#question3
etc. etc.
The problem is if a user links from the content to the form - and then goes back to the content - any other links on content.html will either open another window/tab (if no target reference is used) or if a target reference is used form.html will be reloaded losing form data.
The ideal situation follows:
The user is looking at content.html and clicks a link
Another window or tab opens showing form.html
The user fills in that part of the form and goes back to content.html
The user clicks another link on content.html
The window or tab showing form.html scrolls to the correct anchor point.
I'm not even sure if this is possible but I'm interested in people's thoughts on this problem.
This can be done with basic JS - but rather than writing out the event handlers to listen for that - I just simplified the concept here:
http://jsfiddle.net/fMfgk/
The key is in the name parameter of window.open - keep that the same and you can keep referencing the same window.

Open a link to new tab inside a ifame of iframe

I have a iframe-1 and it contains another iframe-1-1.[1]
Inside iframe-1-1 which contains a link.
When a user click the link:
It should open a new tab (For instance, Firebug/or Chrome).[2]
But it does not work. How can I do that?
[1] Why I have this question: because I code a webpage, it is embedded in Facebook, and I call FB.dialog it will show me a dialog is a iframe too.
[2] It works properly if I use wheel button to click.
You can't instruct a browser to open a new tab. The best you can do is to use target="_blank" and hope that the user is using a browser that will open a tab and not a new window.

How do I open a different page depending upon if user selects open in new tab or not

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
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.
Link
Should work
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.