Tuesday, November 24, 2015

Refresh Iframe

We can refresh and Iframe content using one line of code

Edit in plunker

document.getElementById('iframeid').src += '';

In this example we can reset the position of the map based on button click



<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="style.css">
    <script src="script.js"></script>
  </head>
  <body>
    <h1>Refesh Iframe</h1>
   <iframe id="iframeid" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d124433.84229438548!2d74.94505063237858!3d12.936132829962546!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3ba359d3fded3e01%3A0x189ad1b48a51d6d9!2sKudupu%2C+Karnataka%2C+India!5e0!3m2!1sen!2sus!4v1448375650350" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>   
   <input type="button" id="btn" value="refresh" />
  </body>

</html>
<script>
  function reload() {
    document.getElementById('iframeid').src += '';
} btn.onclick = reload;
</script>

No comments:

Post a Comment