javascript refresh the src of an iframe when it has an anchor

0

I have this javascript that changes the src attribute of an iframe when I click on a link (placing the id of that link as url.

function changeFrame(newPage){
    document.getElementById('myframe').src = newPage;
  } 

It works fine but in some cases I need you to address a URL with an anchor for example: pagina.html # slider-1

The first time it works well but if I click on another link that goes to the same page with a different anchor, for example: pagina.html # slider-5. It does not refresh it, although iframe's url does change, it still shows the first anchor.

Any ideas so that after assigning the url to the iframe it resfresque?

    
asked by Maco Acero 08.06.2017 в 23:10
source

1 answer

0

Try this:

function changeFrame(newPage){
    document.getElementById('myframe').src = "about:blank";
    document.getElementById('myframe').src = newPage;
} 
    
answered by 08.06.2017 в 23:14