Pergunta

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

Foi útil?

Solução 2

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;
       });
    });

Outras dicas

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)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top