이 기사에서는 JS가 가로 채지 않고 Window.open의 구현에 대한 솔루션을 설명합니다. 참조를 위해 공유하십시오. 특정 분석은 다음과 같습니다.
1. 질문 :
오늘, Ajax 요청 페이지를 처리 할 때 요청을 구현 한 후 새 페이지를 열고 싶었고 JS Window를 사용하여 구현하여 구현할 것을 생각했지만 결국 브라우저에서 가로 채 렸습니다.
2. 분석 :
Google 검색에 솔루션이 있습니까? 어떤 사람들은 새로운 A 태그를 만들고 클릭을 시뮬레이션하여 달성 할 수 있다고 말하지만 테스트에서는 달성 할 수 없으며 여전히 브라우저에 의해 가로 채고 있음을 발견했습니다.
마지막으로, 타협 솔루션이 발견되어 A 태그없이 새 페이지를 직접 트래픽하는 효과를 얻을 수 있습니다.
3. 구현 코드 :
코드 사본은 다음과 같습니다. $ obj.click (function () {
var newtab = window.open ( 'about : blank');
$ .ajax ({
성공 : 기능 (데이터) {
if (data) {
//window.open('//www.vevb.com ');
newtab.location.href = "// www.vevb.com";
}
}
})
})
기타 방법 :
다음과 같이 코드를 복사하십시오. <script type = "text/javaScript">
<!-
$ (
기능()
{
// 메소드 1
Window.showmodaldialog ( "// www.vevb.com/");
Window.showmodaldialog ( "// www.vevb.com/");
// 방법 2
var aa = window.open ();
settimeout (function () {
aa.location = "// www.vevb.com";
}, 100);
var b = window.open ();
settimeout (function () {
B.location = "// www.vevb.com";
}, 200);
var c = window.open ();
settimeout (function () {
C.location = "// www.vevb.com";
}, 300);
var d = window.open ();
settimeout (function () {
D.Location = "// www.vevb.com";
}, 400);
var ee = window.open ();
settimeout (function () {
ee.location = "// www.vevb.com";
}, 500);
var f = window.open ();
settimeout (function () {
f.location = "// www.vevb.com";
}, 600);
var g = window.open ();
settimeout (function () {
g.location = "// www.vevb.com";
}, 700);
var h = window.open ();
settimeout (function () {
H.location = "// www.vevb.com";
}, 800);
var i = window.open ();
settimeout (function () {
i.location = "// www.vevb.com";
}, 900);
var j = window.open ();
settimeout (function () {
j.location = "// www.vevb.com";
}, 1000);
// 방법 3
var a = $ ( "<a href = '// www.vevb.com'target = '_ blank'> Apple </a>") .get (0);
var e = document.creeevent ( 'mouseevents');
e.initevent ( 'click', true, true);
a.dispatchevent (e);
var a = $ ( "<a href = '// www.vevb.com'target = '_ blank'> Apple </a>") .get (0);
var e = document.creeevent ( 'mouseevents');
e.initevent ( 'click', true, true);
a.dispatchevent (e);
}
);
//->
</스크립트>
이 기사의 설명이 JavaScript를 기반으로 한 모든 사람의 웹 프로그래밍에 도움이되기를 바랍니다.