2010-07-23 7 views
0

버튼의 javascript onclick에서 직접 cgi 파일을 실행하고 있습니다. cgi는 doc, xls, exe 등의 파일을 반환하고, SavaAs 대화 상자를 열어 클라이언트가 자신의 컴퓨터에 파일을 저장할 수 있도록합니다. 여러 cgi 파일이 for/while 루프에서 실행될 때 문제가 발생합니다. 첫 번째 cgi 만 실행하고 SaveAs 대화 상자를 엽니 다. SaveAs가 열리면 "for"루프가 다시 열리는 다른 cgi를 실행하지 않습니다. 다른 이름으로 저장 대화 상자.자바 스크립트에서 cgi를 호출 할 때 문제가 발생했습니다.

for(i = 0; i < dataPopup.elements['checkbox'].length; i++)  
{ 
    j=0; 
    obj = dataPopup.elements['checkbox']; 
    if(obj[i].checked) 
    { 
     var temp=obj[i].value; 
     temp = temp.split("."); 
     if(temp[1] == "txt") 
     { 
      saveWins[temp[1]] = setTimeout("document.location='../cgi/saveTextFile.cgi?fname=070319185708701_1'", 100); 
     } 
     else if(temp[1] == "pdf") 
     { 
      saveWins[temp[1]] = setTimeout("document.location='../cgi/savePdfFile.cgi?fname=065726729272220_1'", 100); 
     } 
     else if(temp[1] == "xls") 
     { 
      saveWins[temp[1]] = setTimeout("document.location = '../cgi/saveXlsFile.cgi?fname=288433243743'", 100); 
     } 
     else if((temp[1] == "doc") || (temp[1] == "docx")) 
     { 
      saveWins[temp[1]] = document.location = '../cgi/saveDocFile.cgi?fname='+temp[0]; 
     } 
     saveWins[temp[1]].focus(); 
    } 
} 

이 제발 도와주세요 - 여기

코드 조각입니다.

답변

1

설정 document.location은 현재 문서를 새 문서로 바꿉니다 (다운로드 한 경우에도). 즉, 더 이상 스크립트를 실행하지 않아도됩니다.

대신 iframe의 위치를 ​​설정해야합니다.

+0

답장을 보내 주셔서 감사합니다. 왜 작동하지 않는지 이유가 있지만 "대신 iframe의 위치를 ​​설정해야합니다."라는 의미는 무엇입니까? 어떤 iframe을 가져 가고 계십니까? – Neha

0

RoToRa는 document.location을 사용하는 대신 페이지에 숨겨진 iFrame을 삽입하고 window.frames[iframeName].location을 사용하여 iframe의 위치를 ​​변경해야한다는 것을 의미합니다.

관련 문제