Through its unique features, flex can communicate with browsers and demonstrate related operation encapsulation classes.
Package COM. shine. framework. browser {import COM. shine. framework. core. util. arraymap; import flash.net. URLRequest; import flash.net. navigatetoURL; import MX. managers. browsermanager; import MX. managers. ibrowsermanager; import MX. utils. urlutil; public class browserutils {public function browserutils () {}// set the browser title public static function setbrowsertitle (value: string): void {browsermanager. getinstance (). settitle (value);} // obtain all the URLs of the browser static function getbrowserfullurl (): String {var BM: ibrowsermanager = browsermanager. getinstance (); BM. init (); Return BM. URL;} // obtain the URL without the URL public static function getbrowserbaseurl (): String {var BM: ibrowsermanager = browsermanager. getinstance (); BM. init (); Return BM. base;} // obtain the current browser URL protocol public static function getbrowserprotocol (): String {var BM: ibrowsermanager = browsermanager. getinstance (); BM. init (); Return urlutil. getprotocol (BM. URL);} // obtain the current browser URL Port Public static function getbrowserport (): int {var BM: ibrowsermanager = browsermanager. getinstance (); BM. init (); Return urlutil. getport (BM. URL);} // obtain the name of the current browser URL server public static function getbrowserservername (): String {var BM: ibrowsermanager = browsermanager. getinstance (); BM. init (); Return urlutil. getservername (BM. URL);} // modify the current urlpublic static function updatebrowserurl (value: arraymap): void {var BM: ibrowsermanager = browsermanager. getinstance (); BM. init (); var O: Object = urlutil. stringtoobject (BM. fragment); var num: Int = value. getlength (); For (var I: Int = 0; I <num; I ++) {o [value. getkeybyindex (I)] = value. getvaluebyindex (I);} BM. setfragment (urlutil. objecttostring (o);} // obtain the URL server name and port public static function getbrowserserverwithport (): String {var BM: ibrowsermanager = browsermanager. getinstance (); BM. init (); Return urlutil. getservernamewithport (BM. URL);} // refresh the public static function refreshbrowser (): void {navigatetoURL (New URLRequest ("javascript: location. reload (); ")," _ Self ") ;}// close the public static function closebrowser (): void {navigatetoURL (New URLRequest (" javascript: window. close () ")," _ Self ");}}}