Reputation:
I have a link that opens a small popup (not a new tab) to a page. I would like to integrate this function into a button. Unfortunately this doesn't work as hoped.
Good example link:
<a href='#' onclick='window.open **
("https://google.com","mywindow",
"menubar=1,resizable=1,width=500,height=500")'>
Link</a>
Current button that should do the same:
<form>
<input class="btnstylega" onclick="window.location.href='https://google.com'" type="button" value="Link" />
</form>
Upvotes: 0
Views: 4030
Reputation: 408
This is happening because you are setting the window location in one and not creating a new window.
This amended code should work as intended:
<form><input class="btnstylega"
onclick="window.open('https://google.com','mywindow',
'menubar=1,resizable=1,width=500,height=500')"
type="button" value="Link" /></form>
Upvotes: 0
Reputation:
Use _blank
with the target
attribute; this will open a new tab:
<form>
<input class="btnstylega" type="button" value="Neue Versicherung hinzufügen" target="_blank" />
</form>
Or if you want to open a new window, use the onClick
attribute:
<button class="button" onClick="window.open('http://www.example.com');">
<span class="icon">Open</span>
</button>
Here, do NOT forget the quotation marks around the "window.open('http://www.example.com');"
.
Upvotes: 0
Reputation: 5895
why you not try:
<form><input class="btnstylega" onclick="window.open('https://google.com','mywindow',
'menubar=1,resizable=1,width=500,height=500')"
type="button" value="Neue Versicherung hinzufügen" /></form>
Upvotes: 3