So I want open a new window/tab and use
<script>
function popunder() {
window.open("", '_blank', 'toolbar=yes, location=yes, status=yes, menubar=yes, scrollbars=yes').blur();
}
</script>
and it works, but I want forward the main page to a new website link at the same time when "window.open" open...
I use onclick="popunder()"
too.
I have tried
window.location.href
and window.location.replace
but it doesn't work.
Also I have no experience of code at all.
How can I forward the main page to another link with the same click which calls window.open?
So I want open a new window/tab and use
<script>
function popunder() {
window.open("https://link.here", '_blank', 'toolbar=yes, location=yes, status=yes, menubar=yes, scrollbars=yes').blur();
}
</script>
and it works, but I want forward the main page to a new website link at the same time when "window.open" open...
I use onclick="popunder()"
too.
I have tried
window.location.href
and window.location.replace
but it doesn't work.
Also I have no experience of code at all.
How can I forward the main page to another link with the same click which calls window.open?
Share Improve this question asked Nov 23, 2018 at 18:42 apriestkoseapriestkose 11 gold badge1 silver badge1 bronze badge 2- 1 basically the same code, but remove '_blank' and replace with '_self' – zfrisch Commented Nov 23, 2018 at 18:43
-
Did you try doing this on a regular
<a>
link? – charlietfl Commented Nov 23, 2018 at 18:47
1 Answer
Reset to default 2If you'd like to use window.open
the magic lies in the second parameter (the window name that should be affected) You can read more here : https://developer.mozilla/en-US/docs/Web/API/Window/open
window.open("http://google.", "_blank");
// the above opens a new window/tab
window.open("http://bing.", "_self");
// the above navigates to a new page.
Note on StackOverflow the google popup won't register because it's ing from within the sandbox. You can see a demonstrable version of the above code in this fiddle (be sure not to have your popup blocker on)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745410926a4626530.html
评论列表(0条)