Hugo Leonardo
Hugo Leonardo

Reputation: 21

refresh of page within the iframe for other page

First, I apologize for my English evil. I am using a translator. I put a ' refresh ' the page to redirect it after 45 seconds. As I do for this page to load only within the iframe? Thanks

<html>
  <head>
    <title>My title</title>
    <meta http-equiv="refresh" content="45;URL=http://otherpage.com.br">
    </head>
  </head>
  <body>
    <div>
        <iframe style="border: medium none ; overflow: hidden; width: 800px; height: 300px;" src="page2.html" frameborder="0" scrolling="no"></iframe>
    </div>
  </body>
</html>

Don't work.. :(

<html>
  <head>
    <title>My title</title>
<script>
setInterval(function(){
var url = 'http://stackoverflow.com/';
document.getElementsByTagName('iframe')[0].src = url;  }, 45000);
</script>
    </head>
  </head>
  <body>
    <div>
        <iframe style="border: medium none ; overflow: hidden; width: 800px; height: 300px;" src="page2.html" frameborder="0" scrolling="no"></iframe>
    </div>
  </body>
</html>

Upvotes: 0

Views: 1123

Answers (3)

Rayon
Rayon

Reputation: 36609

Try this:

<html>
<head>
    <title>My title</title>
    <meta http-equiv="refresh" content="45;URL=http://otherpage.com.br">
</head>
<body>
    <div>
        <iframe style="border: medium none ; overflow: hidden; width: 800px; height: 300px;"
                src="index.html"
                frameborder="0"
                scrolling="no"></iframe>
    </div>
    <script>
        setInterval(function()
        {
            console.log("here");
            var elem=document.getElementsByTagName('iframe')[0];
            elem.src=elem.getAttribute("src");
        }, 45000);
    </script>
</body>
</html>

Upvotes: 0

Parth Patel
Parth Patel

Reputation: 824

You have a problem of "X-Frame-Options' to 'SAMEORIGIN".

Now, What does it(X-Frame-Options' to 'SAMEORIGIN) mean?

Ans: It means that the site owner do not want anybody to open his/her site in iframe because for security point of view it is poor to have a site to be opened in iframe.

You can check out the link : How Can I Bypass the X-Frame-Options: SAMEORIGIN HTTP Header?

Upvotes: 0

hungndv
hungndv

Reputation: 2141

Here you are:

JQuery:

setInterval(function(){
    var url = 'http://stackoverflow.com/';
    $('iframe').prop('src', url);
}, 45000);

Or Javascript:

setInterval(function(){
    var url = 'http://stackoverflow.com/';
    document.getElementsByTagName('iframe')[0].src = url;
}, 45000);

Upvotes: 2

Related Questions