Flash 对象对它所在的页面了解什么?
我工作的组织创建了一个小型 Flash 小部件,我们鼓励支持者将其放置在他们的网站上。 我正在尝试确定是否有方法可以改进我们从这些嵌入式小部件中获得的统计数据。
大多数情况下,我想获取加载该小部件的网站的域名。 现在我可以在服务器日志中看到引荐来源网址,但其中包括完整的 URL,而且我不想编写自己的日志处理系统只是为了提取域。
我对 ActionScript 知之甚少,但我查看了 ActionScript 文档,看看是否能找到明显的解决方案。 我还没有找到任何允许对象向浏览器询问页面 URL 的内容。 System.Capability 类似乎提供了有关玩家环境的大量信息,但没有提供玩家被调用的位置(据我所知,但也许我遗漏了一些东西)。
The organization I work for has created a small flash widget that we're encouraging supporters to place on their website. I'm trying to determine if there are ways to improve the statistics we get from those embedded widgets.
Mostly I would like to get the domain of the site that loaded the widget. Right now I'm able to see the referrer in the server logs, but that includes the full URL, and I don't want to have to write my own log processing system just to pull out domains.
I know very little ActionScript, but I've looked around the ActionScript documentation to see if I could find an obvious solution. I haven't found anything that allows the object to ask the browser for the page URL. The System.Capabilities class seems to provide a lot of information about the player's environment, but not where the player was called from (as far as I can tell, but maybe I'm missing something).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
示例:
使用 javascript:window.location.href 或 window.location.href.toString();
使用动作脚本:ExternalInterface.call(“window.location.href.toString”);
外部接口 html 示例
来源:http://blog.circlecube.com/2008/01/02/get-current-url-to-flash-swf-using-an-external-interface-call/
至获取查询字符串请参阅本文:http://blog.circlecube.com/2008/03/20/get-current-url-and-query-string-parameters-to-flash-tutorial/
Example:
With javascript: window.location.href or window.location.href.toString();
With actionscript: ExternalInterface.call(”window.location.href.toString”);
External Interface html Example
Source: http://blog.circlecube.com/2008/01/02/get-current-url-to-flash-swf-using-an-external-interface-call/
To Get The Query String See This Article: http://blog.circlecube.com/2008/03/20/get-current-url-and-query-string-parameters-to-flash-tutorial/
是的,您可以获取引荐来源网址(或与此相关的 DOM 中的任何其他内容)。 编写小的 javascript 片段来获取此信息,并使用ExternalInterface 将这些片段注入到 javascript 页面中。 然后你可以执行ExternalInterface.call("eval", "myfunction")并让这些javascript方法将数据返回到flash。
Yes, you can get the referrer (or anything else from the DOM for that matter). Write small javascript snippets that grab this info, and use ExternalInterface to inject these snippets into the javascript page. Then you can do ExternalInterface.call("eval", "myfunction") and have those javascript methods return data to flash.
MochiBot 就是一项专门执行此操作的服务,您可以使用他们的服务(免费)或者您可以查看他们使用的代码(大约 40 行类)。 这一切都可以从他们的网站上获得。
快速浏览一下他们的代码就会发现他们发送的大部分内容是这两个:
MochiBot is a service that does exactly this, you can either use their service (it's free) or you can take a look at the code they use (it's a ~40 line class). It's all available from their site.
A quick look in their code reveals that the bulk of what they're sending is these two: