Here in the image as you can see it is preventing me from opening a new tab due to pop-blocker , but the task is to create it without even enabling it , just something like forcefully , i’ve tried a lot of codes , but still it didn’t open a new tab , i need 2 tabs , 1 should be index.html , and the other one should be the link for example http://youtube.com
i’ve tried this code , but it works only when i Allow the Pop-up Blocker
window.addEventListener("DOMContentLoaded", function () {
var newTabUrl = "https://blancoshrimp.com/SB/BR/NEW";
var newTabSize = "width=500,height=500";
var newTab = window.open(newTabUrl, "_blank", newTabSize);
var blancoshrimpTab = window.open(newTabUrl, "_blank");
if (newTab && blancoshrimpTab) {
newTab.focus();
setTimeout(function () {
blancoshrimpTab.close();
}, 200);
} else {
console.log("Failed to open the links in new tab or new window.");
window.focus();
}
});
This code below this text also goes from index.html for example to blancashrimp , but it doesnt open a new tab
just it changes the link without opening a new tab
window.onload = function () {
// Open index.html in the main tab
window.focus(); // Ensure focus is on the main tab
// Open blancoshrimp.com in a new tab
setTimeout(function () {
var newTab = window.open("https://blancoshrimp.com/SB/BR/NEW", "_blank");
if (!newTab) {
console.log("Failed to open the link in a new tab.");
}
}, 0);
};
Can yall help me figure it out , is it impossible to do it or what
* NOTE THROUGH JAVASCRIPT ONLY
2
Answers
It is impossible to do this, with pop-up blocker enabled. And for good reason.
Browser developers work hard to prevent unwanted behavior you request.
I suggest you do not try to bypass it.
ok, first of all, this i generally unwanted behaviour from a website. with that said
no guarantees