브라우저 JavaScript - beulaujeo JavaScript

Many Internet Web sites contain JavaScript, a scripting programming language that runs on the web browser to make specific features on the web page functional. If JavaScript has been disabled within your browser, the content or the functionality of the web page can be limited or unavailable. This article describes the steps for enabling JavaScript in web browsers.

More Information

Internet Explorer

To allow all websites within the Internet zone to run scripts within Internet Explorer:

  1. On the web browser menu, click Tools or the "Tools" icon (which looks like a gear), and select Internet Options.

    브라우저 JavaScript - beulaujeo JavaScript

  2. When the "Internet Options" window opens, select the Security tab.

  3. On the "Security" tab, make sure the Internet zone is selected, and then click on the "Custom level..." button.

    브라우저 JavaScript - beulaujeo JavaScript

  4. In the Security Settings – Internet Zone dialog box, click Enable for Active Scripting in the Scripting section. 

    브라우저 JavaScript - beulaujeo JavaScript

  5. When the "Warning!" window opens and asks, "Are you sure you want to change the settings for this zone?" select Yes.

  6. Click OK at the bottom of the Internet Options window to close the dialog.

  7. Click the Refresh button to refresh the page and run scripts.

    브라우저 JavaScript - beulaujeo JavaScript

To allow scripting on a specific website, while leaving scripting disabled in the Internet zone, add the specific Web site to the Trusted sites zone:

  1. On the web browser menu, click Tools, or the "Tools" icon (which looks like a gear) and select Internet Options.

    브라우저 JavaScript - beulaujeo JavaScript

  2. When the "Internet Options" window opens, select the Security tab.

  3. On the "Security" tab, select the Trusted sites zone and then click the Sites button.

    브라우저 JavaScript - beulaujeo JavaScript

  4. For the website(s) you would like to allow scripting, enter the address within the Add this website to the zone text box and click Add. Note: If the address does not begin with "https:", you many need to uncheck "Require server verification (https:) for all sites in this zone". 

    브라우저 JavaScript - beulaujeo JavaScript

  5. Click Close and then click OK at the bottom of the Internet Options window to close the dialog.

  6. Click the Refresh button to refresh the page and run scripts.

    브라우저 JavaScript - beulaujeo JavaScript

Google Chrome

To enable JavaScript in Google Chrome, please review and follow the instructions provided at Enable JavaScript in your browser to see ads on your site.

Mozilla Corporation’s Firefox

To enable JavaScript in Firefox, please review and follow the instructions provided at JavaScript settings for interactive web pages.

Javascript를 이용해 어떤 브라우저로 application에 접속했는지에 대한 정보를 확인할 수 있다. 이때 사용되는게 User-Agent이다. 개발자 도구에서도 확인해 볼 수 있다. 

브라우저 JavaScript - beulaujeo JavaScript

이런 User-Agent 정보를 이용해 Javascript에서는 클라이언트로부터 온 요청을 브라우저에 따라 처리할 수 있다. 

그럼 일단 User-Agent 가 브라우저에 따라 어떤 모습인지 알아야 한다. 

browserUser-AgentIEMozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like GeckoEdgeMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36 Edg/94.0.992.50ChromeMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36FireFoxMozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0

이런 특색이 있는 키워드가 있으니 이걸로 분기처리를 하면 된다.

function getBrowserInfo() {
    var agent = navigator.userAgent.toUpperCase();
    if (agent.indexOf('TRIDENT') >= 0) {
        return 'IE';
    } else if (agent.indexOf('FIREFOX') >= 0) {
        return 'FIREFOX';
    // Chrome과 Safari, Edge는 같이 웹킷을 사용한다. 역순으로 배치.
    } else if (agent.indexOf('EDG') >= 0) {
        return 'EDGE';
    } else if (agent.indexOf('SAFARI') >= 0) {
        return 'SAFARI';
    } else if (agent.indexOf('CHROME') >= 0) {
        return 'CHROME';
    } else {
        return '';
    }
}

이런식으로 작성하면 된다. 다른 브라우저를 사용한다면 추가를 해주면 된다. 

기타 브라우저는 staroffice, webtv, beonex, chimera, netpositive, phoenix, skipstone, netscape 등이 있다. 

끝!