1

我正在尝试做这样的事情: 例子

我希望能够根据下拉列表中选择的选项动态更改 iframe。

我到目前为止的代码是这样的:

    <html>
    <head>
    <script>
        function hidem() {
        document.getElementById('Select').style.display = "none";
        document.getElementById('test1').style.display = "none";
        document.getElementById('test2').style.display = "none";
        }
    function changeIt(divid) {
        hidem();
        document.getElementById(divid).style.display = "block";
    }
    </script>
    </head>

    <table border="0">
        <tr>
            <td>
                <select id="Manage" onChange="changeIt(this.value)">
                <option value="Select">Select A Management Window</option>
                <option value="test1">Google</option>
                <option value="test2">Yahoo</option>
                </select>
            </td>
            <td>
                <div id="Select">
                    <h2>Information:</h2>
                    This is a management console
                </div>
                <div id="test1" style="display:none">
                    <h2>Google:</h2>
                    <iframe src="http://www.google.com" width="100%" height="100%"></iframe>
                </div>
                <div id="test2" style="display:none">
            <h2>Yahoo:</h2>
                    <iframe src="http://www.yahoo.com" width="100%" height="100%"></iframe>
                </div>
            </td>
        </tr>
    </html>

但它似乎并没有按照我的意图工作。有人能帮我解决这个问题吗?

谢谢你,

戴夫

4

1 回答 1

0

尽管有大量无效的 HTML 错误(@BillyMoat 在评论中强调了这些错误),但我不相信您能够按照您的计划进行操作。

许多大型网站(尤其是 Google)X-Frame-Options: SAMEORIGIN在其页面上使用 。

这意味着不允许浏览器在父级来自不同来源(即域)的框架中显示页面......这当然取决于浏览器理解该指令,大多数当前浏览器都会这样做。

Mozilla 标头的详细信息

这是一个博客,列出了有关标头的更多详细信息,包括将阻止正在加载的页面的浏览器列表

于 2012-08-28T16:40:46.620 回答