browser back button causes an iframe to be navigated - html

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.

Related

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

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.

How to enable middle-mouse clicks on iFrames?

I have an iframe which simply displays a slideshow of our different products. It's hosted on the same server, it was just easier to use an iFrame.
Each slide contains a link to the current product on the slide, i couldn't use an href on the anchors, so instead i used " onclick='window.top.location.href =...' ". (This also prevents right clicks for the links.)
So my question is can i enable middle mouse clicks (and right clicks) for the links so that we can open them in a new tab, or would i have to go back to using an href.
Note - The reason i used onclick instead of href, was because with href the link would open inside the iframe instead of changing the top page. Is there another way to circumvent this and still keep normal clickability? Thanks in advance guys :)
Why you are not using a tag with target attribute?it will open link in new window.
add target="_blank"

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?

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.

Break the Iframe

I have an iframe on a landing page and I want to break the frame upon the viewers submit. When the viewer goes to the second page the frame cuts the image on the page is there a way to break, if I don't control the iframed page submit button. Could i frame my own button over the existing and have it scripted to "push" both buttons one to break the frame and the other to carry to the second page? I would prefer to have script to break on submit but how would the page know when the button is pushed?
Unless you control both the framed page and the page that contains the frame, and they're both within the same domain, you're probably not going to be able to do this.