Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, there is a javascript function in my webpage as following :

XML
<script type="text/javascript" language="javascript">
<!--
//initializing the WebPlayer
var u = new UnityObject2();
u.initPlugin(jQuery("#unityPlayer")[0], "Example.unity3d");

function SaySomethingToUnity(value)
{
    u.getUnity().SendMessage("GUI", "ChangeText", value);
}
-->
</script>



i want to call and send parameters to above js method " SaySomethingToUnity " as url parameter.
as an example " https://www.google.lk/search?q=test " i can pass parameter like this.

like wise i want to pass parameters into my SaySomethingToUnity js function that in eg : www.mytest.com
Posted

1 solution

I was found a solution from
XML
http://stackoverflow.com/questions/2405355/how-to-pass-a-parameter-to-a-javascript-through-a-url-and-display-it-on-a-page

here is the soultion :

var GET = {};
var query = window.location.search.substring(1).split(&quot;&amp;&quot;);
for (var i = 0, max = query.length; i &lt; max; i++)
{
    if (query[i] === &quot;&quot;) // check for trailing &amp; with no param
        continue;

    var param = query[i].split(&quot;=&quot;);
    GET[decodeURIComponent(param[0])] = decodeURIComponent(param[1] || &quot;&quot;);
}
Usage: GET.Use_id or GET[&quot;Use_id&quot;]. You can also check if a parameter is present even if it has a null value using &quot;Use_id&quot; in GET (will return true or false).</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900