Posted By

chrisaiv on 12/04/08


Tagged

javascript as3 bridge


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

cessnajumpin
THEPWN3R
ozke
dx0ne
tspitzr
jondiscipulo


As3: Capture the HREF, Pathname, Host, userAgent


 / Published in: ActionScript 3
 

Here's how I was able to capture the HREF of a page using actionscript

  1. //Here's a list of helpful items to capture
  2. var pageURL:String = ExternalInterface.call('window.location.href.toString');
  3. var pageHost:String = ExternalInterface.call('window.location.hostname.toString');
  4. var pagePath:String = ExternalInterface.call('window.location.pathname.toString');
  5. var pageProtocol:String = ExternalInterface.call('window.location.protocol.toString');
  6. var userAgent:String = ExternalInterface.call('window.navigator.userAgent.toString');
  7. var platform:String = ExternalInterface.call('window.navigator.platform.toString');
  8.  
  9.  
  10. private function getQueryString():String
  11. {
  12. var query:String = ExternalInterface.call("window.location.pathname.toString");
  13. //ExternalInterface.call("window.location.href.toString");
  14. return query;
  15. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: justtoknowmoreaboutjava on October 29, 2009

This is possible only when allowScriptAccess is set to"always" in tag but in most of the website like myspace they set allowScriptAccess to samedomain and in this case we are not allowed to use ExternalInterface.

Do we have any alternate way to get the browser URL - not the location of swf.

Please suggest.

Thank You, Lasavi

You need to login to post a comment.