IT관련/Angular

탐색 확인 팝업창이 두번째 클릭부터 뜨는 이유

파란하늘999 2025. 6. 25. 13:19

브라우져를 열고 처음 클릭하면 열리지 않고

두번째클릭부터는 잘 열린다.

 

이유가 뭘까?

 

 

0.1초였었는데 1초로 변경하니 되네...

 

클로드(AI)의 답변으로는 iframe 로딩 지연때문이라고 한다.

 

const url = `호출프로그램::${command}`;
      
      // 파라미터 추가
      const queryParams = params 
        ? Object.entries(params)
            .map(([key, value]) => {
              const encodedValue = encodeURIComponent(
                typeof value === 'object' ? JSON.stringify(value) : String(value)
              );
              return `${key}=${encodedValue}`;
            })
            .join('&')
        : '';
      
      const fullUrl = queryParams ? `${url}?${queryParams}` : url;
      
      // 1. 숨겨진 iframe 생성 방식
      try {
        const iframe = document.createElement('iframe');
        iframe.style.display = 'none';
        iframe.src = fullUrl;
        document.body.appendChild(iframe);
        
        // 잠시 후 iframe 제거
        setTimeout(() => {
          document.body.removeChild(iframe);
          resolve(null);
        }, 1000);
      } catch (e) {
        console.error('호출 오류:', e);
        reject('호출 오류');
      }
반응형