iexplre에서는 되는데 edge에서는 작동이 안되는 이유가?

iexplre에서는 되는데 edge에서는 작동이 안되는 이유가?

QA

iexplre에서는 되는데 edge에서는 작동이 안되는 이유가?

본문

그누보드 4 환경에서 개발한 사이트입니다.

그런데~ 갑자기 브라우저 환경문제인지 java 문제인지 도통 알수가 없네요~ ㅠㅠ

 

오류부분만 소스를 올려봅니다. ㅠㅜ

 

<form name="category" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">

<input type=hidden name="mode" value="<?=$mode?>" />

....

<!-- 버튼영역 -->

<input type="button" value="분류수정" class="order_btn" onClick="javascript:up('분류수정')">

<input type="button" value="선택삭제" class="order_btn" onClick="javascript:del1()">

 

<!-- 체크박스영역 -->

<input type=hidden name=ca_id[<?=$i?>] value="<?=$row[ca_id]?>">

<input name="chk[]" type="checkbox" value="<?=$i?>" />

 

<!-- 자바스크립트 영역 -->

<script language='Javascript'>

var f = document.category;

 

function up(str) {    //분류수정
    var chk = document.getElementsByName("chk[]");
    var bchk = false;
    var intk = 0;
    var inti = 0;
    var stri=0;

    for (i=0; i<chk.length; i++)
    {
        if (chk[i].checked){
            bchk = true;
            intk++;
            inti = i;
        }
    }

    if (!bchk) 
    {
        alert(str + "할 자료를 한개 선택하세요.");
        return;
    }

    if(intk > 1)
    {
        alert(str + "할 자료를 한개만 선택하세요.");
        return;
    }
    
    stri =  f.elements("ca_id["+inti+"]");
    stri =  document.getElementById("ca_id["+inti+"]");

 

    popupWindow = window.open('./cate_add1.php?ca_id='+stri.value+'&mode=up1','category','left=800,top=400,width=460,height=245,scrollbars=0');
}

 

function del1(str)    //삭제
{
    var chk = document.getElementsByName("chk[]");
    var bchk = false;
    var intk = 0;
    var inti = 0;
    var stri= "";


    for (i=0; i<chk.length; i++)
    {
        if (chk[i].checked){
            bchk = true;
            intk++;
            inti = i;
        }
    }

    if (!bchk) 
    {
        alert("삭제할 자료를 한개 선택하세요.");
        return;
    }

    if(intk > 1)
    {
        alert("삭제할 자료를 한개만 선택하세요.");
        return;
    }

    stri =  f.elements("ca_id["+inti+"]");
    //f.ca_id01.value = stri.value;

    if(confirm("카테고리를 정말 삭제하시겠습니까?")){
        f.mode.value = "del1";
        f.action = './cate_update.php';
        f.submit();
    }else {
        return;
    }

}

</script>

 

이렇게 코드(소스)가 있습니다.

이때 분류수정을 위해 체크박스를 선택해서 분류수정을 누르면, 아무반응이 없습니다.

하나도 선택안하면 분류수정할 자료를 한개 선택하세요.

두개 선택하면 분류수정할 자료를 한개만 선택하세요. 여기까지는 잘 됩니다.

 

그런데 한개를 선택하고 실행버튼을 누르면 반응이 없네요!!!!

개발자모드(F12)를 눌러서 오류를 확인하면

Console 오류는 

Uncaught TypeError: Cannot read property 'elements' of undefined

Souress에는 

stri =  f.elements("ca_id["+inti+"]"); (X)

여기에 오류가 있다고 나옵니다.

 

제가 개발자가 아니다보니.. 어떤 문제인지 몇일째 고생만 하고 있습니다.

값을 못 얻어오는건지.. 자바스크립트 오류인지 ㅠㅠ

희안한건 iexplore에서는 작동이 또 잘됩니다. 

구글이나 Microsoft Edge에서만 작동이 안되네요~~ common, head.sub.php 관련된 모든 부분도 체크를 했는데 원인을 모르겠네요~ ㅜㅠ 브라우저가 바뀌면서 뭔가 충돌이 나는건지도...ㅠㅠ

도움을 부탁드려요!~ 

 

이 질문에 댓글 쓰기 :

답변 3

f.elements

면 변수 f의 엘리먼트들을 가져와라 라고 하는건데

 

각 함수가 쓰여진곳에 변수 f의 정의가 내려지지않았습니다

 

var f = document.category;의 정의가 지금 함수 밖에있는데요 이게 밖에있으면안되고

각 함수(function)안에 들어가있어야합니다

 

밖에있는 변수 f의 정의를 함수안으로 각각 넣어주세요

script 안에 function이 여러 개 존재합니다.
function { 안에
f의 정의: var f = document.category; 를 추가했는데도

동일하게 stri =  f.elements("ca_id["+inti+"]"); (x)
오류는 동일하게 보여지네요... ㅠㅠ 일단, 아무반응이 없네요~ ㅠㅠ
제가 잘 못하고 있는지도..ㅠ ㅠ

네.. 
function up에 아래와 같이 추가했습니다.
 

function up(str) {    //분류수정
    var f = document.category;
    var chk = document.getElementsByName("chk[]");
    var bchk = false;
    var intk = 0;
    var inti = 0;
    var stri=0;

    for (i=0; i<chk.length; i++)
    {
        if (chk[i].checked){
            bchk = true;
            intk++;
            inti = i;
        }
    }

    if (!bchk) 
    {
        alert(str + "할 자료를 한개 선택하세요.");
        return;
    }

    if(intk > 1)
    {
        alert(str + "할 자료를 한개만 선택하세요.");
        return;
    }
    
    stri =  f.elements("ca_id["+inti+"]");

//    alert(inti+"="+stri.value);

    popupWindow = window.open('./cate_add1.php?ca_id='+stri.value+'&mode=up1','category','left=800,top=400,width=460,height=245,scrollbars=0');
}

 

위와 같이 추가하는게 맞나요??? 

function up(str){ 바로 아래 추가해도 아무반응 없어서...

 

var f = document.category;

stri =  f.elements("ca_id["+inti+"]");

 

위처럼.. f.elements 바로 위에도 추가해서 테스트를 해봤는데 아무런 반응이 없네요~ ㅠㅠ

세션문제인지..ㅠㅠ 

ㅠㅠ 캐시 초기화해서 다시 실행해도 안되네요~
동일하게 아무반응이 없어서 f12 개발자모드 Sources를 체크하면 동일한 코드에 붉은색 x로 표시되네요~ ㅠㅠㅠㅠ

개발자모드 콘솔에서 document.category한번 찍어보세요

위 정보를 찍어본다는게 무슨말씀인지 모르겠네요 ㅠㅠ
해당 파일 내
<form name="category" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
위와같이 존재해서요~ ㅠㅠ

도움주셔서 감사합니다. 역시 개발자가 아닌관계로 잘 안되네요~~ ㅠㅠ

var f = document.category;

->

var f = document.forms['category'];

답변을 작성하시기 전에 로그인 해주세요.
전체 123,524 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT