I want my cookies details to open in a new window popup in my Chrome browser when i click on it.
This is my code-
</div>
<a href="javascript:window.open('','_self').close();">
<label className="return"><T.span text='Cookies.Homepage' /></label>
</a>
</div>
<Link to="/Cookies" target="_blank">
<T.span text='Footer.Cookies'/>
</Link>
But this always opens the cookies content in a new tab. How can i open it in a separate new window popup??
To open the new window in an actual window, and not a tab, you need to pass in a specs parameter to window.open:
javascript:window.open('','_blank','height=600,width=400');
Use blank instead of self
<a href="javascript:window.open('','_blank').close();">
Related
I am using the code below to open a new tab upon clicking a bootstrap button in a razor .cshtml page currently. I have a button in the new tab opened which returns to the main menu, but I would like to know how to close this tab, to effectively return to where the user was previously.
<ul class="nav nav-sidebar">
<!-- Menu Item -->
<li class="menuItem">
<a asp-controller="New Tab Section Menu" asp-action="Index" target="_blank" class="menuItemLabel">
<i class="fas fa-book-reader fa-lg" style="padding-right: 5px"></i>
New Section Menu
</a>
</li>
You can't close browser tabs this simple.
I assume that you have a return button. What you can use target="_self" instead of target="_blank" so no tab will open and you can navigate back.
You could use window.close() in Javascript before, but this is mostly unavailable EXCEPT when you open a new tab with target="_blank" or by script.
In your case it might be worth a try.
Use a button with:
Return to base!
Browsers are very picky about this for security and useability reasons.
https://stackoverflow.com/a/66688958/6803592
I want to have a button on a page that links to a .pdf in a new tab (easy enough) but I also want that button to trigger the loading of a new url in the original tab. (So when the user closes the tab with the .pdf they see a new page has loaded in the original tab underneath.) Possible?
<a href="https://w3schools.com/" onclick="openNewTab()">
<button type="button">Click me btn</button>
</a>
<script>
function openNewTab() {
window.open('https://google.com', '_blank').focus();
}
</script>
Using link for open another page outside of project
<div class="info-line">
<mat-icon class="s-20 ml-2">
language
</mat-icon>
<a class="h3" href="https://www.google.kz/">
Web Page
</a>
</div>
but when click to link, opened this page: http://localhost:4200/google.kz - local page, not "google.kz"
How to make, open google.kz outsite link, not trying to find in local page?
You can use target="blank" as follows.
<a class="h3" href="https://www.google.kz/" target="_blank">
target
Where to display the linked URL, as the name for a browsing context (a tab, window, or iframe).
_blank: usually a new tab, but users can configure browsers to open a new window instead.
It should work the way you've described it, but another way of doing it is using the document.location api.
Example:
<div class="info-line">
<mat-icon class="s-20 ml-2">
language
</mat-icon>
<a class="h3" (click)="navigate()">
Web Page
</a>
</div>
inside your component:
navigate(){
document.location = "https://www.google.kz/"
}
I have two links in my page with target="_blank", but if i open the first link in a new tab, when i click in the second, the page loads in tha tab that the first link are already open, i need to make they open in different tabs, not in the same. Thanks.
Add the code...
<ul style="float: left;">
<li><span>Help Desk</span></li>
<li><span>Bússola</span></li>
</ul>
target="_blank" is the correct (and possibly the only) way to do this but how it behaves depends on the browser and browser settings.
See HTML: how to force links to open in a new tab, not new window for more details.
A workaround might be to give them different names like so:
<ul style="float: left;">
<li><span>Help Desk</span></li>
<li><span>Bússola</span></li>
</ul>
That should force the browser to open two new tabs and if you click the first link, then always the same frame will reload (same for the second tab).
Try with javascript function like this
Html:
Target
Javascript:
<script>
function open_win()
{
window.open("https://www.google.co.in/");
}
</script>
https://stackoverflow.com/a/18764547/1428854
I am working on localhost:
I have kept
`<a href="www.facebook.com" target="_tab">
<div> </div>
</a>`
On button click it should redirect and open in new tab. But it shows following url in next tab
http://dev01.dev/Umesh/www.facebook.com
ie. localhost/current<dir>/url
rather
url
Your target is wrong, it should be
target="_blank"
change www.facebook.com to http://facebook.com. Also there is no such thing as _tab what you want is _blank.