BrowserUtility ã¯ã©ã¹ã¨ã¯
Flashãããã©ã¦ã¶ä¸ã®æ
å ±â¦â¦ä¾ãã°URLããã©ã¦ã¶ã®ç¨®é¡ã®å¤å®ãªã©ãè¡ãå ´åãFlashã®APIã¨ãã¦ã¯ç´æ¥æä½ã§ããªããã§ãããã
ãªã®ã§ãFlashâJSã®ã©ã¤ãã©ãªã§ãããExternalInterfaceã£ã¦ã®ã使ããªãã¦ã¯ãããªãã
ã§ãæ¯åå¿
è¦ã«ãã¾ããã¦ããã³ãã¤ã³ããªåä½ã ãæ¸ãã®ãé¢åã¨ãããDRYãããªãã®ã§ãã©ã¤ãã©ãªã«ãã¡ããã°è¯ãããããã¨ããæµãã§ãã
BrowserUtility ã«ã¤ãã¦
ãªãã¸ããªãªã©
ç°¡åãªèª¬æ
ã¾ãããã®ã©ã¤ãã©ãªã§ã¯ä¸ã¤ã®ã¯ã©ã¹ãæä¾ãã¾ãã
- BrowserUtility ã©ã¤ãã©ãªã®ã¡ã¤ã³ã¯ã©ã¹
- Browser ãã©ã¦ã¶ããã¼ã¸ã§ã³å¤å®ç¨ã¯ã©ã¹
- Location JS ã® window.location ç¸å½ã®ã¯ã©ã¹
ãã ããBrowserUtility ã®ã¯ã©ã¹ä»¥å¤ã¯ç´æ¥ä½¿ç¨ãããã¨ã¯ãªãã§ãããã
主ãªã¯ã©ã¹
import com.github.sugamasao.browser_utility.*; BrowserUtility.browser.isIE // true or false BrowserUtility.browser.version // 8 BrowserUtility.location.href // http://example.com
ä¸è¨ã®ããã«ãBrowserUtilityã¯ã©ã¹ã® static ã¡ã½ãããå¼ã¶ãã¨ã§ãå
é¨ã§ã¯ã©ã¹ãçæããã¾ãã
ã¾ããä¸åº¦ExternalInterfaceã§åå¾ãããã¼ã¿ã¯ãã£ãã·ã¥ãããã®ã§ãã¡ã½ãããå¼ã¶åº¦ã«ExternalInterfaceãå®è¡ããããããªãã¨ã¯ããã¾ããã
ãã ããæ示çã«ExternalInterfaceã使ç¨ãã¦åå¾ãã¦ãããã¼ã¿ãæ´æ°ãããå ´åã¯ä»¥ä¸ã®ããã«ãã¾ãã
import com.github.sugamasao.browser_utility.*; BrowserUtility.refreshBrowser.isIE // true or false BrowserUtility.refreshLocation.href // http://example.com
refreshãã®ã¡ã½ããã使ç¨ãããã¨ã§ãExternalInterfaceã«ãããã¼ã¿ã®åå¾ãæ¹ãã¦è¡ãã¾ãã
Browserã¯ã©ã¹ã«ãããã©ã¦ã¶å¤å®å¯¾å¿
以ä¸ã®ãã©ã¦ã¶ãå¤å®ãã¾ãã
ã¾ããã¼ã¸ã§ã³æ
å ±ã«ã¤ãã¦ããä¸è¬çãªã¡ã¸ã£ã¼ãã¼ã¸ã§ã³ã»ãã¤ãã¼ãã¼ã¸ã§ã³ã¯æ¾ãã¦ãã¾ãã
ä¾ãã°ãSafari ãªãã° 1.0 1.1 1.2 2.0 3.0 ... ã¨ãã£ãå
·åã§ãã
Location ã¯ã©ã¹ã§åå¾ã§ããæ å ±
JSã«ãã window.location.hogehoge ã§åå¾ã§ãããã®ã¨ã¾ã£ããåä¸ã§ãã
æå¾ã«
ãã©ã¦ã¶å¤å®ã®ãã¹ããã¼ã¿ã¨ãã¦ãä¸è¨ã®ãã¼ã¸ã®ã¦ã¼ã¶ã¨ã¼ã¸ã§ã³ãä¸è¦§ã使ç¨ããã¦é ãã¾ãããæè¬ã§ãã
ã¨ããããã§ãèå³ããããæ¹ã¯ãBrowserUtilityã使ã£ã¦ã¿ã¦ãã ããã