program tip

ie8 var w = window.open ()-“메시지 : 유효하지 않은 인수.”

radiobox 2020. 7. 24. 20:22
반응형

ie8 var w = window.open ()-“메시지 : 유효하지 않은 인수.”


IE8 전용 문제가있는 사이트가 있습니다.

코드는 다음과 같습니다

var w = window.open(urlstring, wname, wfeatures, 'false');

오류는 다음과 같습니다

메시지 : 잘못된 인수입니다.
줄 : 419 Char : 5
코드 : 0
URI : http : //HOSTNAME/js_context.js

코드의 줄 번호 ( "줄"및 "URI"가 올바른지)를 확인했으며 이후 버전의 IE8에서는 이것이 정확한 것으로 간주됩니다.

경고를 덤프하여 호출의 모든 수신 매개 변수를 확인했으며 모두 유효 해 보입니다.

이 문제는 FF (아마도 3)에서는 발생하지 않습니다.

최신 정보:

"var w"를 수행 할 때 window.open ()의 결과를 할당하는 데 문제가있는 것 같습니다. 줄을 두 개의 문장으로 나누면 IE8에서 작동합니다.

UPDATE2 :

기준 :

http://javascript.crockford.com/code.html

함수가 즉시 호출되는 경우, 생성 된 값이 함수 자체가 아니라 함수의 결과라는 것이 확실해 지도록 전체 호출 표현식을 구문으로 랩핑해야합니다.

이것은 여기서 일어나는 일이 아니지만 IE8의 호환 모드에서 원리를 적용하면 문제가 해결된다는 것을 알았습니다.

var w = (window.open(urlstring, wname, wfeatures, false));

이것은 오래된 게시물이지만 누군가에게 여전히 유용 할 수 있습니다.

같은 오류 메시지가 나타났습니다. 결국 문제는 두 번째 인수의 잘못된 이름입니다. 즉, 다음과 같은 줄이 있습니다.

   window.open('/somefile.html', 'a window title', 'width=300');

문제는 유효하지 않기 때문에 '창 제목'이었습니다. 다음 줄에서 잘 작동했습니다.

   window.open('/somefile.html', '', 'width=300');

사실,주의 깊게 읽으면 Microsoft가 name두 번째 주장으로 지원하지 않는다는 것을 깨달았습니다 . 당신이 볼 때 공식 문서 페이지 , 당신은 전혀 그 인수를 사용하는 경우 Microsoft는 다음 인수를 허용 참조 :

  • _공백
  • _미디어
  • _부모의
  • _검색
  • _본인
  • _상단

IE는 창 이름 인수에 대해 까다 롭습니다. 공백, 대시 또는 기타 문장 부호를 좋아하지 않습니다.


window.openIE 를 호출 할 때 두 번째 인수 (창 이름)는 사전 정의 된 대상 문자열 중 하나 이거나 JavaScript에서 유효한 식별자 형식 을 갖는 문자열 이어야합니다 .

Firefox에서 작동하는 것 : "Job Directory 9463460" 은 Internet Explorer에서 작동 하지 않으며 "Job_Directory_9463460"으로 대체해야합니다 (예 : 공백, 빼기 부호, 점 없음, 유효한 식별자 여야 함) .


문제는 wname 일 수 있습니다. 위의 링크에 표시된 것 중 하나를 사용하십시오.

선택 과목. 창의 이름을 지정하는 문자열. 이 이름은 양식 또는 앵커 요소에서 TARGET 속성의 값으로 사용됩니다.

  • _blank sURL이 이름이없는 새 창에로드됩니다.
  • _media URL은 Microsoft Internet Explorer 6의 미디어 표시 줄에로드됩니다. Microsoft Windows XP 서비스 팩 2 (SP2) 이상. 이 기능은 더 이상 지원되지 않습니다. 기본적으로 URL은 새 브라우저 창 또는 탭에로드됩니다.
  • _parent sURL은 현재 프레임의 부모에로드됩니다. 프레임에 부모가없는 경우이 값은 _self 값으로 작동합니다.
  • _search Windows Internet Explorer 7에서 비활성화 됨 자세한 내용은 Internet Explorer 7의 보안 및 호환성을 참조하십시오. 그렇지 않으면 Internet Explorer 5 이상의 브라우저 검색 창에서 sURL이 열립니다.
  • _self 현재 문서가 지정된 sURL로 바뀝니다.
  • _top sURL은로드 될 수있는 모든 프레임 세트를 대체합니다. 정의 된 프레임 세트가 없으면이 값은 _self 값으로 작동합니다.

다른 wname을 사용하면 window.open이 실행되지 않습니다 ...


실제로 이름을 사용할 수는 있지만 공백을 사용할 수 window.open("../myPage","MyWindows",...)없으므로 문제없이 작동해야합니다 ( window.open ).


다음 코드를 사용하는 동안이 문제를 만났습니다.

window.open('test.html','Window title','width=1200,height=800,scrollbars=yes');

but when I delete the blank space of the "Window title" the below code is working:

window.open('test.html','Windowtitle','width=1200,height=800,scrollbars=yes');

Hi using the following code its working...

onclick="window.open('privacy_policy.php','','width=1200,height=800,scrollbars=yes');

Previously i Entered like

onclick="window.open('privacy_policy.php','Window title','width=1200,height=800,scrollbars=yes');

Means Microsoft does not allow you to enter window name it should be blank in window.open function...

Thanks, Nilesh Pangul


For me the issue was with a dash "-" in the window name field. I removed the dashes and IE does not error out and in fact opens the window.


What does position four represent, the one that has 'false' as an value? Shouldn't that be false, (i.e. without quotes?). It's possible that earlier versions of IE would coerce the string to a boolean, but newer ones don't.


The answers here are correct in that IE does not support spaces when setting the title in window.open(), none seem to offer a workaround.

I removed the title from my window.open call (you can use null or ''), and hten added the following to the page being opened:

<script>document.title = 'My new title';</script>

Not ideal by any means, but this will allow you to set the title to whatever you want in all browsers.


Try remove the last argument. Other than that, make sure urlstring, wname, and wfeatures exist.


I discovered the same problem and after reading the first answer that supposed the problem is caused by the window name, changed it : first to '_blank', which worked fine (both compatibility and regular view), then to the previous value, only minus the space in the value :) - also worked. IMO, the problem (or part of it) is caused by IE being unable to use a normal string value as the wname. Hope this helps if anybody runs into the same problem.


If you want use the name of new window etc posting a form to this window, then the solution, that working in IE, FF, Chrome:

  var ret = window.open("", "_blank");
  ret.name = "NewFormName";

  var myForm = document.createElement("form");
  myForm.method="post";
  myForm.action = "xyz.php";
  myForm.target = "NewFormName";

      ...

It seems when even using a "valid" custom window name (not _blank, etc.) using window.open to launch a new window, there is still issues. It works fine the first time you click the link, but if you click it again (with the first launched window still up) you receive an "Error: No such interface supported" script debug.

참고URL : https://stackoverflow.com/questions/710756/ie8-var-w-window-open-message-invalid-argument

반응형