ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Opener에 객체 생성할 때 IE/FF 호환성 (jQuery와 Option플러그인 이용)
    Digital Life/볼만한 이야기 2009. 4. 23. 20:10
    jQuery를 이용했습니다.

    응용하면 없이도 가능합니다.


    키포인트는,

      Opener의 문서
    Option 객체 생성
    Opener에 객체 생성
     IE  window.opener.document  document.createElement('option')  window.opener.document.createElement('option')
     Non-IE  opener.document  new Option
     new Option(?)



    function registerComponentToKiosk() {
        var resultList = document.getElementById('componentSelect');
        var moduleName = document.getElementById('module_name').value;

        var result_srl = resultList.value;
        var resultText = resultList.options[resultList.selectedIndex].text;

       
       
        try { // IE 왕따
            var targetList = $('#kiosk_component_list', window.opener.document)[0];
            for (var i = 0; i < targetList.length; i++) {
                if (targetList.options[i].value == result_srl) {
                    alert ('같은 부품이 있습니다.');
                    return false;
                }
            }
            var targetObj = window.opener.document.createElement('option');
            targetObj.text = moduleName + ' - ' + resultText;
            targetObj.value = result_srl;
            targetList.add (targetObj);
        } catch (ex) { // 기타 다른 브라우져
            var targetList = $('#kiosk_component_list', opener.document);
            if ($('#kiosk_component_list > option[value=' + result_srl + ']').length > 0) {
                alert ('같은 부품이 있습니다.');
                return false;
            }
            targetList.addOption(result_srl, moduleName + ' - ' + resultText );
        }
        window.close();
    }
Designed by Tistory.