At Specialmoves we maintain a very large multi-lingual Flash site for a luxury brand. As part of a recent update we noticed that there appeared to be some issues with the url and title of the browser not updating. It was only certain pages and happened in most languages. The problem became even stranger when we realised that it was only happening on Macs.
After a little debugging I soon found the issue. SWFAddress actually does a check to detect the OS and calls JavaScript functions differently on a Mac. On Windows (and other Operating Systems) SWFAddress uses ExternalInterface to call JavaScript functions. However, on a Mac it sends a string of JavaScript to the browser by using NavigateToURL.
Why the difference? I’m not sure to be honest but I presume it may be something to do with making multiple calls in quick succession with ExternalInterface.call() not working in some browsers on a Mac? That’s just a guess though and I don’t have time to do tests and find out the definite reason. The difference is mentioned in this old blog post on the Asual site but there is no explanation given why.
Anyway, back to why it was not updating on certain pages for our site update. The issue was that some of the translators had accidentally added a carriage return to the title on some pages. Probably caused from copying and pasting from an Excel or Word document. This carriage return was fine when using ExternalInterface but using NavigateToURL it meant the JavaScript was not valid and therefore never gets called.
The fix was simple, I changed this line in our code:
to this:
This removes any carriage returns and ensures the JavaScript will be called successfully.
I think this is perhaps a little flaw with SWFAddress. Sure we developers should ensure we’re sending a title or URL without a carriage return. However, there is no way that the JavaScript will work with NavigateToURL if it contains a carriage return, so I think it wouldn’t hurt for there to be a little check within SWFAddress. I have contacted Asual and suggested this for the next code release.