如何根据URL参数加载Iframe源 [英] How to load Iframe source based on URL parameter

查看:174
本文介绍了如何根据URL参数加载Iframe源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Code Projet!



我想拥有:

- 包含指向不同播放列表的多个链接的页面

- 带有iframe的页面B加载选定的播放列表



到目前为止,我有这个页面B:

http://sg-cms.azurewebsites.net/opespe/travel2/boarding.php?id=summer-1



应该在iframe中加载此页面: http://soundsgoood.com/playlist/summer-1



但我无法得到?id = summer-1来相应地更改iframe源。 br />


这是页面B代码:



Hi Code Projet !

I would like to have :
- a page A with several links to different playlists
- a page B with an iframe to load the selected playlist

So far, I have this page B :
http://sg-cms.azurewebsites.net/opespe/travel2/boarding.php?id=summer-1

That should load this page in the iframe : http://soundsgoood.com/playlist/summer-1

But I can't get the ?id=summer-1 to change the iframe source accordingly.

Here is the page B code :

<html>
    <head>
    </head>
    <body> 
        <div id="header">
            <a href="index.html">Back</a>
        </div>

        <iframe id="myIframe" src="http://soundsgoood.com/playlist/" style="width:100%; height:1000px;"></iframe>

        <script>
        (function() {
            var frameBaseSRC = document.getElementById("myIframe").src;
            var frameQueryString = document.location.href.split("id=")[1];
            if (frameQueryString != undefined) {
                document.getElementById("myIframe").src = frameBaseSRC + "?id=" + frameQueryString;
            }
         })();
         </script>
    </body>
</html>





我在这里想念什么? (我是新手,srory ^^)。



L.



What do I miss here ? (I'm a novice, srory ^^).

L.

推荐答案

为什么不给你用其他方式替换de iframe,如Web Parts,ContentPlaceHolder等?有了这个,你的源代码就有了更多的控制权和可访问性。



iFrames不安全,很多防火墙阻止了iframe



问候
why dont you replace de iframe for another way like Web Parts, ContentPlaceHolder etc? with this you have more control and accessibility on your source code.

iFrames isn't secure and many firewalls block iframes

Regards


这篇关于如何根据URL参数加载Iframe源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆