简体   繁体   English

将父窗口的变量获取到iframe网址

[英]GET variables of parent window to iframe url

I'm trying to pass on the parent url variables to the variables of the iframe url. 我正在尝试将父网址变量传递给iframe网址变量。

For example if the parent url is: http://mywebsite.com/autos-zoeken?sessid=s838c7e5c3be0452fc38f4ffb6f307ed7&code=be3f&whsearch_key=6568 例如,如果父网址为: http : //mywebsite.com/autos-zoeken? sessid= s838c7e5c3be0452fc38f4ffb6f307ed7& code= be3f& whsearch_key= 6568

The iframe url needs to become: http://anotherwebsite.com/s838c7e5c3be0452fc38f4ffb6f307ed7/be3f/stock/6568/ iframe网址需要变为: http : //anotherwebsite.com/s838c7e5c3be0452fc38f4ffb6f307ed7/be3f/stock/6568/

The code I'm using now is: 我现在使用的代码是:

<?php $val1 = $_GET[“sessid“]; $val2 = $_GET[“code“]; $val3 = $_GET[“whsearch_key“]; echo "<iframe src='http://anotherwebsite.com/' . $val1 . '/' . $val2 . '/stock/' . $val3 . '/' id='blockrandom' width='1000' height='1200' scrolling='auto' frameborder='0' class='wrapper'> Your browser doesn't support inline frames.</iframe>"; ?>

The result on the website is: http://anotherwebsite.com/' . 网站上的结果是:http://anotherwebsite.com/'。 . '/' . '/' . '/stock/' . '/股票/' 。 . '/' id='blockrandom1' etc '/'id ='blockrandom1'等

So the variables aren't being put in the right place in the iframe url 因此,变量没有被放置在iframe网址中的正确位置

What am I doing wrong here? 我在这里做错了什么?

this should work fine: 这应该工作正常:

echo "<iframe src='http://anotherwebsite.com/$val1/$val2/stock/$val3/' id='blockrandom' width='1000' height='1200' scrolling='auto' frameborder='0' class='wrapper'> Your browser doesn't support inline frames.</iframe>";

the problem is with all your quote's inside your src, it thinks it needs to stop your src after http://anotherwebsite.com/ and you don't need to use "." 问题在于您的src中包含所有引号,它认为需要在http://anotherwebsite.com/之后停止您的src,并且您无需使用“”。 inbetween because you used doubleqouote on start, you can just use variables inside doublequotes. 两者之间,因为您在开始时就使用了doubleqouote,因此可以只在doublequotes中使用变量。

    echo "<iframe src='http://anotherwebsite.com/$val1/$val2/stock/$val3/' id='blockrandom' width='1000' height='1200' scrolling='auto' frameborder='0' class='wrapper'>Your browser doesn't support inline frames.</iframe>"; ?> 

您不需要转义变量

You're not actually concatenating multiple strings, you're just building a single string. 您实际上并没有串联多个字符串,而只是构建一个字符串。 Take a look at a simplified example: 看一个简化的例子:

"<iframe src='http://anotherwebsite.com/' . $val1"

That's just one string which happens to have a period between some spaces. 那只是一个字符串,恰好在某些空格之间有一个句点。 In order to use the . 为了使用. concatenation operator you need to terminate the string first: 串联运算符,您需要先终止字符串:

"<iframe src='http://anotherwebsite.com/'" . $val1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM