在 url 的查询字符串中传递字母数字值在 Flash 中不起作用
我有一个 Flash 应用程序,我想通过 javascript 从 defaul.aspx 页面向它发送参数。
我有一个名为 Id 的参数,它可以接受字母数字值。
如果我只输入 Id 数字,则 url 中的查询字符串可以正常工作,并将我带到与该 id 相关的特定页面,但如果我输入数字和字符(如 001A )的组合,则它不起作用。
这是我使用的代码
<script type="text/javascript">
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0; i<vars.length; i++)
{
var pair = vars[i].split("=");
if (pair[0] == variable)
return (pair[1]);
}
}
</script>
,后来我将 Flash 应用程序的第一页分配给它。
flashvars.StartPage = getQueryVariable("Id");
然后将 flashvars 传递到 swfobject.embedSWF
我也不想更改 flash 端的 mxml 文件中的任何内容
如果有人可以帮助我解决问题,我很
感激
I am having a flash application where I want to send paramters to it via the javascript from a defaul.aspx page.
I have a paramter called Id where it can accept alphanumerica values.
the query string in the url works fine if I enter just numbers for the Id, and takes me to the specific page relted to that id , but if I enter a combination of numbers and characters like 001A , it does not work.
this is the code I used
<script type="text/javascript">
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0; i<vars.length; i++)
{
var pair = vars[i].split("=");
if (pair[0] == variable)
return (pair[1]);
}
}
</script>
and then later I assigned the first page of flash application to it.
flashvars.StartPage = getQueryVariable("Id");
and then passed the flashvars into swfobject.embedSWF
I also don't want to change anything in my mxml files in flash side
I appreciate if anyone could help me what the problem is
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,您不需要使用 JavaScript 处理查询字符串中的值,然后发送到 flash。
只需使用
ExternalInterface.call
函数从 URL 中获取变量(在本例中为 GET )。这是它的工作原理的代码。将此代码添加到您的 MXML 中。
因此,如果您的网址类似于 http://www.stackoverflow.com/page.aspx?id= 230A78&id2=8934
arrVals[0]
包含 230A78,arrVals[1]
包含 8934No you don't need to use JavaScript to process the value from querystring and then to send to flash.
Just make use of
ExternalInterface.call
function to grab variables (In this case : GET ) from URL.Here's the code how it works. Add this code inside your MXML.
So if your URL is like http://www.stackoverflow.com/page.aspx?id=230A78&id2=8934
The
arrVals[0]
contains 230A78 andarrVals[1]
contains 8934