Artikel ini menjelaskan solusi untuk implementasi jendela. Buka tanpa dicegat oleh JS. Bagikan untuk referensi Anda. Analisis spesifiknya adalah sebagai berikut:
1. Pertanyaan:
Hari ini, ketika saya memproses permintaan Ajax Page, saya ingin membuka halaman baru setelah menerapkan permintaan, dan saya berpikir untuk menggunakan JS Window. Buka untuk mengimplementasikannya, tetapi akhirnya dicegat oleh browser.
2. Analisis:
Apakah ada solusi dalam pencarian Google? Beberapa orang mengatakan bahwa itu dapat dicapai dengan membuat tag A baru dan mensimulasikan klik, tetapi tes menemukan bahwa itu tidak dapat dicapai dan masih dicegat oleh browser.
Akhirnya, solusi kompromi ditemukan, yang dapat mencapai efek dari perdagangan halaman baru secara langsung tanpa tag A.
3. Kode Implementasi:
Salinan kode adalah sebagai berikut: $ obj.click (function () {
var newtab = window.open ('tentang: blank');
$ .Ajax ({
Sukses: function (data) {
if (data) {
//window.open('//www.vevb.com ');
newtab.location.href = "// www.vevb.com";
}
}
})
})
Metode lain:
Salin kode sebagai berikut: <script type = "text/javascript">
<!-
$ (
fungsi()
{
// Metode 1
window.showmodaldialog ("// www.vevb.com/");
window.showmodaldialog ("// www.vevb.com/");
// Metode 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);
// Metode 3
var a = $ ("<a href = '// www.vevb.com' target = '_ blank'> apel </a>") .get (0);
var e = document.createEvent ('MouseEvents');
E.Initevent ('klik', benar, benar);
a.dispatchevent (e);
var a = $ ("<a href = '// www.vevb.com' target = '_ blank'> apel </a>") .get (0);
var e = document.createEvent ('MouseEvents');
E.Initevent ('klik', benar, benar);
a.dispatchevent (e);
}
);
//->
</script>
Saya berharap deskripsi dalam artikel ini akan bermanfaat untuk pemrograman web semua orang berdasarkan JavaScript.