问题描述
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.
推荐答案
这篇关于如何根据URL参数加载Iframe源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!