Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Get Browser Url from .swf file

Guest
Aug 02, 2009 Aug 02, 2009

Hi!

Quick question... I need to get the browser`s url from a html-embeded swf file.

If the browser`s url is "http://www.mysite.com/stuff/myHtml.html?ln=en", I need to have access to it through my swf file in order to find the value of the ln (language) parameter. Any suggestions?...

Thank you

TOPICS
ActionScript
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 02, 2009 Aug 02, 2009

a swf can only get its own url which won't help when the query string is appended to the embedding xml file.

you can use:

function urlF(){
return location.href;
}

Translate
Community Expert ,
Aug 02, 2009 Aug 02, 2009

use javascript to obtain the url and use the externalinterface class to pass the url to flash.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 02, 2009 Aug 02, 2009

So there is no direct way to get the url into flash?...

The thing is that I`m making some multi-languaged banners for another programmer. The url`s used in his site have a ln parameter from which I could get the language.

So then... I could call a JavaScript function with ExternalInterface from flash and get the url then move on with my bussiness form there, right? I dont`t know Java script though... You think you could give me the code?... Thanks in advance!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2009 Aug 02, 2009

a swf can only get its own url which won't help when the query string is appended to the embedding xml file.

you can use:

function urlF(){
return location.href;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 02, 2009 Aug 02, 2009

Thank you very much

I was googling around for the last hour or so and was currently trying with some php code...

You just saved me a lot of time. It worked.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 02, 2009 Aug 02, 2009

There is another way to do that without using JavaScript directly:

var browserURL:String = ExternalInterface.call("window.location.href.toString");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 02, 2009 Aug 02, 2009

Oh, that`s great! Instead of referencing a JavaScript function you just define it right there...

Just tried it out and it works

Thanks a lot!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 02, 2009 Aug 02, 2009

You are welcome.

Don't forget to check if ExternalInterface exists just to be paranoid.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 02, 2009 Aug 02, 2009
LATEST

If you're only interested in the query string portion of the url, use: window.location.search


ExternalInterface.call("window.location.search.toString");
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines