Three implementation schemes of how to refresh iframe

Time:2021-2-6

Copy code

The code is as follows:

<iframe src=”1.htm” name=”ifrmname”></iframe>

Scheme 1:
Locating with iframe’s name attribute

Copy code

The code is as follows:

<input type=”button” name=”Button” value=”Button” onclick=” document.frames (‘ifrmname’). location.reload () “> or
<input type=”button” name=”Button” value=”Button” onclick=”document.all.ifrmname.document.location.reload()”>

Scheme 2:
Locating with ID attribute of iframe

Copy code

The code is as follows:

<input type=”button” name=”Button” value=”Button” onclick=”ifrmid.window.location.reload()”>

The ultimate solution:
When the SRC of iframe is the address of other websites (cross domain operation)

Copy code

The code is as follows:

<input type=”button” name=”Button” value=”Button” onclick=”window.open(document.all.ifrmname.src,’ifrmname’,”)”>