javascript: history.go(-1) doesnt work for the whole window

i have an unusual problem. I have a page which contains an iframe, which is controlled by the dropdown. So selection of the dropdown loads different iframes. Anyway - on the bottom I have a button to return to the previous page (I mean the whole page, not previously loaded iframe on that page).

<a href="javascript: history.go(-1)">

Unfortunately it also includes the history of these iframes, so when I click on that button, it loads up the previous iframe instead of taking me back.

Here is how to explain it well:

  1. go to this page: Click here

  2. go to the hyperlink on that page

  3. make couple of selections from the drop down (play with it)

  4. click the return button on the very bottom of the page.

I want it to take me back to the first page (here.html), not go back to the previously loaded iframe on 1.html.

I have to use javascript history.go or similar script. I can't use direct link to here.html, as this page is a part of many other pages, so when the user clicks return, he is forwarded to his specific landing page. I greatly appreciate any help.

It's a life-saving question

Answers


You need to remove the newly iframe before sending browser back to the actual page.

Add click event on the return link

HTML:

<a id="return_link" href="#">

Javascript:

    $(document).ready(function() {
        $('#return_link').on('click', function(e) {
        e.preventDefault();
        $('#iframeId').remove();
        window.location = document.referrer;
       });
    });

Use document.referer

var referrer =  document.referrer;
window.location = referrer;

Check if it works !

<a href="javascript: window.location = document.referrer;">

try this , Just remove extra spaces from statements.

href="javascript:history.go(-1)


Need Your Help

Using files as IPC in Linux?

linux ipc

We're writing a program that haves 2 processes. One process reads data from a serial device, and the other process consumes this data and sends it to the network.

Drawing few graphs with "chart" VS C#

c# graph colors charts series

friends! I want to ask you another easy question - how to draw another graph in chart.series? That's what I have: