3

I have a button which when clicked the first time displays an iframe. The source of the iframe is a text log file.

I would like that whenever the same button is clicked/toggled, the iframe would be refreshed too in case the log file is updated.

Here is my code so far:

HTML

<button id="displaylog">Display Log</button>

<iframe id="ramka" src="@Url.Action("OpenFile", "File")" style="display:none"></iframe>

jQuery

$(document).ready(function () {

    $("#displaylog").click(function () {
        $("#ramka").show();
    });

});
1
  • Just use document.getElementById(FrameID).contentDocument.location.reload(true); to reload your iframe Commented Sep 1, 2017 at 8:46

2 Answers 2

4

To Reload an iFrame in jQuery

$( '#ramka' ).attr( 'src', function ( i, val ) { return val; });
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect! Thank you much.
0

You should be able to achieve it with this short piece of code JavaScript

document.getElementById("ramka").src = document.getElementById("ramka").src

Jquery

$("#ramka").prop("src", $("#ramka").prop("src"))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.