获取iframe变量url的值

时间:2016-10-07 02:13:00

标签: javascript php iframe

我想看看这个例子:

http://www.siteexemple.com/pagina.php?url=http://www.variablevalue.com

在我的php:pagina.php中我有iframe:

 <Iframe src = "" width = "100%" height = "100%" scrolling = "no" frameborder = "0" allowFullScreen = "true"> </ iframe>

现在我如何得到变量``url to the iframe src = ""

的值

我想得到的结果是:

 <Iframe src = "http://www.variablevalue.com" width = "100%" height = "100%" scrolling = "no" frameborder = "0" allowFullScreen = "true"> </ iframe>

已经尝试过:

 <Iframe src = "<? Php echo $ url;?>" Width = "100%" height = "100%" scrolling = "no" frameborder = "0" allowFullScreen = "true"> </ iframe>

但它没有用,我提前感谢你的关注谢谢!

1 个答案:

答案 0 :(得分:0)

使用$ _GET [&#34; url&#34;]而不是$ url。

<Iframe src = "<?php echo $_GET["url"]; ?>" Width = "100%" height = "100%" scrolling = "no" frameborder = "0" allowFullScreen = "true"> </ iframe>

请注意,如果包含未编码的URL作为变量,则可能会导致某些转义异常。我建议使用urlencode()和urldecode()提前处理这些变种。