Flash Player 7載入外部數據的壞消息和好消息 | (12-09-2003) |
在Flash Player 6或以前,利用loadVariables()、loadVariablesNum()、LoadVars()、XML.load()等載入外部數據,是不可以跨Domain,即在domainA.com的Flash不可以載入在domainB.com的數據(需要通過Middleware作中間人)。但載入Sub Domain的數據是容許,即放在www.luar.net、luar.net、foo.luar.net的Flash都可以載入在此3個不同的Sub Domain的數據。 Flash Player 7卻帶來了壞消息,它收緊了安全政策,載入Sub Domain的數據是不容許,不過這只對使用了Absolute Path的Flash有影響,例如loadVariablesNum("http://www.domainA.com/data.txt", 0),一般Web Server都可以設定短網址,例如http://domainA.com,如果Flash通過短網址載入,那麼載入外部數據就會受到影響。 Flash 6版本的Flash,在Flash Player 7播放會出現警告字句,需要訪客決定是否准許載入外部數據: Flash 7版本的Flash,在Flash Player 7播放就索性沒有警告字句,根本載入外部數據的動作已經被否決了。 解決方法,製作一個名叫crossdomain.xml,放在外部數據的Server的root,即http://www.domainB.com/crossdomain.xml。XML文件裡,有一行: <allow-access-from domain="" /> 你可以自行加入容許路徑,例如: <allow-access-from domain="*" /> 通過加入crossdomain.xml,因此也帶來一個好消息,Flash Player 7可以載入跨Domain的外部數據!無論是Flash 6或7版本的Flash,只要在Flash Player 7播放,domainB.com的Server有crossdomain.xml這文件,裡面有: <allow-access-from domain="*.domainA.com" /> 或 在domainA.com的Flash就可以載入它的數據。 補充 |
||
本文章由發表。 |
意見 | |
沒有意見。 |
|
同組文章 |