Strange <iframe> behavior on page reload

I have three simple HTML files in one directory:

index.html

    <html>
        <head>
            <title>Page 1</title>
        </head>
        <body>
            <iframe src="page2.html"></iframe>
        </body>
    </html>

page2.html and page3.html (about the same content)

    <html>
        <head>
            <title>Page 2</title>
        </head>
        <body>
            This is the content of page 2
        </body>
    </html>


    <html>
        <head>
            <title>Page 3</title>
        </head>
        <body>
            This is the content of page 3
        </body>
    </html>

index.html contains <iframe>that points to one of the other two HTML files.

When I load index.htmlfor the first time, it works as expected and prints “This is the contents of page 2”. But when I change the attribute srcto "page3.html" and reload the page, nothing changes. He continues to tell me “This is the contents of page 2,” although he should download page 3.

, (index.html), " 3". page2.html, 3.

. , - .

:

<script>
    document.write(document.querySelector("iframe").src);
</script>

. ( iframe .)

, , , iframe, .

? ?

.

P.S. Firefox 29.

P.S. (2) , .

+4
2

- :

 document.getElementById(FrameID).contentDocument.location.reload(true);

iframe , .

EDIT: Chrome, script.

+2

Iframe, iframe, Javascript ( - FF iframe):

HTML:

<!doctype html>
<html>
    <head>
        <title>Page 1</title>
    </head>
    <body>
        <div id="iframe_wrapper"></div>
    </body>
</html>

Javascript:

document.addEventListener("DOMContentLoaded", function(event) {
    var iframeWrapper = document.getElementById("iframe_wrapper");
    var iframe = document.createElement("iframe");
    iframe.src="http://www.bing.com/";
    iframe.width = "400";
    iframe.height = "400";

    iframeWrapper.appendChild(iframe);
});
0

Source: https://habr.com/ru/post/1539367/


All Articles