How to update 2 iframes with a single link / button using html / js

I am new here and love to know how to update 2 different frames on one page.

I found something on google using getElemenById. But it should work in firefox, and firefox has some problems with Id.

early.

<form action="managecartform.html" onclick="deleteAllCookies();"><button type="submit" >Empty cart</button></form> 
0
source share
2 answers

What does your form have to do with iframes?

Do you mean this? Load the control form in one frame and reload the other?

 <form action="managecartform.html" target="iframe1" onsubmit="deleteAllCookies(); window.frames[0].location.reload(1);"> <input type="submit" value="Empty cart"/> </form> <iframe name="iframe0"></iframe> <iframe name="iframe1"></iframe> 
0
source

Firefox has no problems with identifiers - in 99% of cases this is due to the fact that you either do not have an identifier or the identifier is duplicated.

identifiers must be unique throughout the document.

To answer your question:

 <iframe id="frame1"></iframe> <iframe id="frame2"></iframe> <input type="button" onclick="refreshFrames()" value="refresh frames" /> <script type="text/javascript"> function refreshFrames(){ frame1 = document.getElementById('frame1'); frame2 = document.getElementById('frame2'); if(frame1.contentDocument){ frame1.contentDocument.location.reload(true); frame2.contentDocument.location.reload(true); } else { frame1.contentWindow.location.reload(true); frame2.contentWindow.location.reload(true); } } </script> 

(For IE, you may need to use contentWindow instead of contentDocument depending on the version of IE you are trying to support)

0
source

All Articles