简体   繁体   中英

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:

<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. I have tried by using user_id = ReturnURL() but its not working.

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.

This means that somewhere in your javascript you should have the following code

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

This should work just fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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