我正在创建一个模板演示栏,人们可以在这里查看我创建的web主题。用户将点击一个页面上的预览按钮,并可以在另一个页面中看到iframe中的主题。以下是链接页面的代码
<html>
<head></head>
<body>
<a href="http://site/demobar?theme=http://www.template.com">preview</a>
</body>
</html>
然后在演示页面上,我得到了iframe
<iframe src="<?php echo $_GET['theme']; ?>" style="width:100vw; height:100vh;"></iframe>
这还可以,但我的问题是返回显示url:的url
http://site/demobar/?theme=http://www.template.com
我想要URL 中的模板名称而不是模板地址
http://site/demobar/?theme=themeName
我怎么能做到这一点!!,javascript还有其他选择吗!
首先,设置一个具有可能主题的数组,并根据theme
参数选择合适的主题。。。
<?php
$themes = array(
"theme" => "http://www.theme.com/",
"othertheme" => "http://www.some-other-theme.com/",
);
$themeAddress = $themes[$_GET['theme']];
?>
接下来,参照url生成iframe。。。
<iframe src="<?php echo $themeAddress; ?>" style="width:100vw; height:100vh;"></iframe>
然后调用具有适当主题名称的url:
http://site/demobar/?theme=othertheme