Open URL in new browser tab when click on HTML button - html

I am designing a web site with CodeIgniter and I want to open some URL when user click on its buttons (URLs have to open in new tab).
I use this code and it works when you want to open URL in same tab, but I want the URL to open in a new tab. I don't want to use JavaScript function too.
<button type="button" onclick="location.href='http://google.com'">Google</button>

If you could change your button to be an anchor...
Google
Then you could add styling to your anchor... if this is even required.

Try something like this
<button type = "button" onclick = "location.href = window.open('link')"></button>

Related

HTML button event on click and release

I'm new on HTML and I need to understand some basic stuff for a project with the ESP01 wi-fi module. I would like to create a web page with a button and this one has to have a different behaviour according to if it is pressed or released.
I tried with this
<button onclick='location.href='/UP_ON'' onmouseup='location.href='/UP_OFF''>UP</button>
but it doesn't work.
try location.href
<button onclick='location.href=/?UP_ON' onmouseup='location.href=/?UP_OFF'>UP</button>

Make a button that opens a fresh new tab in HTML, no link, just a new tab

Is it possible to make a button, that when clicked, opens a new tab. Not any link, just a new tab. so far I have <button target="_blank" onclick="location.href = ''">New Tab</button>
Simply link to about:blank with the target _blank
<a target="_target" href="about:blank"><button>New Tab</button></a>
The answer is, its impossible. You can't navigate to the users default home page, as stated by Gradyn Wursten. Though you can navigate to a blank white page, using about:blank

Open in same browser tab from Trello

I am creating a link in a Trello card to an external link. What I want to achieve is that this link opens in the same browser tab ( _self ) or opens in a new browser tab and return to this tab if the link is activated again. As it is now it generates a new browser tab every time clicking the link. Is there any suggestion to achieve this ?
You can set specific window's name, in order to open reuse the tab. You can do the following way.
Foo
Bar
Or this way also..
<div id="tabopen">
link
</div>
<script>
document.getElementById("tabopen").onclick = function(evt){
if (evt.target.tagName === "A")
window.open(evt.target.href, evt.target.href);
return false;
}
</script>
This is a very old question, but I thought I should add that in 2022:
Adding a link as an attachment to the card opens the url in a new tab when you click on it.
Adding a link as text in the description of the card opens the link in the same tab when you click on it.

Open a link to new tab inside a ifame of iframe

I have a iframe-1 and it contains another iframe-1-1.[1]
Inside iframe-1-1 which contains a link.
When a user click the link:
It should open a new tab (For instance, Firebug/or Chrome).[2]
But it does not work. How can I do that?
[1] Why I have this question: because I code a webpage, it is embedded in Facebook, and I call FB.dialog it will show me a dialog is a iframe too.
[2] It works properly if I use wheel button to click.
You can't instruct a browser to open a new tab. The best you can do is to use target="_blank" and hope that the user is using a browser that will open a tab and not a new window.

Make link using submit button

Can I link one page to another page using submit button?
It sends all the wrong signals to the user, but:
<form action="some-uri"><div><input type="submit"></div></form>
The problem with using a submit form is that the next page will think that it has to deal with a binary request, which you can't do if using an upload form.
So you are better using a image button (can make it look like a submit button) or using JavaScript...
Open in a new window:
onClick="window.open('page.html');"
Open in the same window:
onClick="document.location.href = ('page.html');"