Reputation: 73
I am working on a home page and I have an iFrame that i would like to be able to reload using a button.
I have two Javascript files that I will Label "J1" (for the first) and "J2" (for the second) and for the two HTML files I will label them "Hyper1" and "Hyper2".
The issue that I have come across with using the code below:
[Hyper1]
<button style="display: none" id="reload" class="tablinks" onclick="reload()">Reload</button>
[J2]
function reload() {
window.location.reload();
}
so basically I have the code for the button on "Hyper1" and the function on "J2" (which is where the coding for the iframe is) and it still reloads the entire page and not just the iFrame.
I know this is going to seem like a really easy solve but I new to JavaScript so I personally don't know much
Upvotes: 0
Views: 152
Reputation: 1824
Try this
function reload() {
document.getElementById('your_frame_id').src += '?v=' + Math.random();
}
Place this function in your J1.
Upvotes: 1