SWFObject Question:

Download Job Interview Questions and Answers PDF

How to pass URIs or HTML code as a value using flashvars?

SWFObject Interview Question
SWFObject Interview Question

Answer:

Special characters and the symbols = and & cannot directly be used inside flashvars values (the latter because they are used to stack the flashvars themselves).

You can workaround this issue by escaping these characters before passing them as flashvar values. An example:

encodeURIComponent("&trade") will become %26trade

The values will be available in your swf already unencoded, so no unescaping is needed inside your swf.

Note that encodeURIComponent is not available in all browsers, but is available in all of the common modern versions. If you need full backwards compatibility, you can use escape() instead, but note that escape() does not work well with double-byte characters (like Chinese).

You can also escape these characters manually by using:

%3D instead of =
%26 instead of &

Download SWFObject Interview Questions And Answers PDF

Previous QuestionNext Question
How to avoid Active Server Pages error ASP 0139 when using static publishing and Microsoft IIS?How to avoid that extra whitespace is created underneath my SWF?