简体   繁体   中英

HTML basic button code for opening webpage in new window

Newbie question here. The following link works well to open a new window to a specified webpage.

<a onclick="window.open('','page','location=0,toolbar=0,...')"
href="mypage.html" target="page">My Link</a>

I need to replace the link with a button, but can't get it to work. Here's what I've got:

<button onclick="window.open('','page','location=0,toolbar=0,...')" 
href="mypage.html" target="page"
type="button">My Button</button>

It appears that href and target are not attributes of button. Looking for recommendations how to fix this for best browser compatibility.

why not try:

<a onclick="window.open('','page','location=0,toolbar=0,...')"
href="mypage.html" target="page"><button>My Link</button></a>

这应该工作

<button onclick="window.open(yourwebsite+'/mypage.html')">My Button</button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM