I am firing the Window.open();
command. which opens the link page in another tab. what i want is when i click the link, the link will open in new window but should be on the same page.
Is that possible ?
presently i am using like this.
function AddToDatabase(url) {
window.open(url, "_blank");
}
You can simply open a new tab and stay on the same page by: Right clicking the link that you want to open in a new tab. Then select, “Open link in new tab”
How to Open Hyperlinks in a New Browser Tab or Window. The short answer is: just add a target="_blank" attribute to your links (anchor tags). Now when your visitors click that link, it will open in a new window or tab (depending on which web browser they are using and how they configured that browser).
usually href's ar used to transfer the request to another page.. If you want to redirect another page still the existing page remain open use target attribute.. If you dont want to redirect anywhere and still want send a signal while clicking the text, use onclick on the text and not the href.
To open a link in a new browser window, hold the Shift on then click the link or right-click the link and select Open link in New Window.
Use _self instead of _blank.
window.open(url, "_self");
For further details. See This Link
The code you have should not be changing the page. How are you calling AddToDatabase()
? Is it from an a href
tag? If so the default action is taking place from the link and you need to prevent that.
You can set the href attribute to javascript:void(0)
<a href="javascript:void(0)" onclick="AddToDatabase('myUrl')">Add URL</a>
Or you can have the onclick attribute return false
<a href="#" onclick="AddToDatabase('myUrl'); return false;">Add URL</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With