简体   繁体   English

将JavaScript变量从iframe传递到网址

[英]Passing javascript variable from iframe to URL

Lets say I have a function like this: 可以说我有一个像这样的函数:

<script type="text/javascript">

function ReturnURL()
{
var url = document.URL;
var url2 = url.split("=");
var urlID = url2[url2.length-1];


//window.open('http://localhost/POSkill/skillshow.aspx?user_id =' + urlID);
return urlID;
}

</script>

And I also have iframe in my html file which is something like below: 而且我的html文件中也有iframe,如下所示:

<iframe id="showSkill" scrolling="yes" src="http://localhost/POSkill/skillshow.aspx?user_id = ReturnURL()" height="350" runat="server" ></iframe>

Now all I want to do is to send the urlID value of javasrcipt as the user_id value in iframe. 现在,我要做的就是在iframe 中将javasrcipturlID值作为user_id值发送。 I have tried by using user_id = ReturnURL() but its not working. 我已经尝试过使用user_id = ReturnURL(),但无法正常工作。

How can I do this? 我怎样才能做到这一点?

Thanks in Advance. 提前致谢。

I answered something very similar at enter link description here 我在这里输入链接描述时回答了非常相似的内容

The answer is that you must set the "src" value on the JS rendering. 答案是必须在JS渲染上设置“ src”值。

This means that somewhere in your javascript you should have the following code 这意味着您在javascript的某处应该具有以下代码

...
document.getElementById("showSkill").src="http://localhost/POSkill/skillshow.aspx?user_id =" +  ReturnURL()
...

This should work just fine. 这应该很好。

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

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