Is another site/URL using my Flash SWF?

October 27, 2007 | Uncategorized | 3 Comments

There is not a clear way in Flash access what site is using your SWF. On DTS's media page, we allow users to embed our media player in their blogs (like all other video sites these days), but it is difficult to know the URL of the file who is pulling the file. stage.loaderInfo.url is just the URL of the SWF, but not the HTML page which embeds the SWF. The only way I found to do this is to call ExternalInterface and ask JavaScript what the URL of the page is. So here's what I came up with:

var urlReferrer:String = ExternalInterface.call("document.location.href.toString"); 

The reason for the "toString() is that ExternalInterface.call wants you to use a function rather than just calling a static property.

Update (01/08/08): Looks like someone else has caught on to this.

3 responses to “Is another site/URL using my Flash SWF?”

  1. Evan Mullins says:

    Thanks! I was having trouble with this- until you pointed out the toString has to be called. Makes sense, why didn’t I think of that?

  2. Evan Mullins says:

    Actually this doesn’t seem to be working with msie 6 or 7.
    Works like a charm for firefox and any others I’ve tested…

    Any suggestions?

  3. John Dyer says:

    I’ve noticed that it works in IE when you use SwfObject (http://blog.deconcept.com/swfobject/) or when use both the object and embed tags, but it won’t work if you only use the embed tag.

Leave a Reply

Hi, I'm John Dyer. In my day job, I build websites and create online seminary software for a seminary in Dallas. I also like to release open source tools including a pretty popular HTML5 video player and build tools that help people find best bible commentaries and do bible study. And just for fun, I also wrote a book on the theology of technology and media.

Fork me on GitHub

Social Widgets powered by AB-WebLog.com.