Javascript onclick open in new tab

ONCLICK="window.location.href='http://www.google.com'"

How can I change that to open in a new tab.
rivkamakAsked:
Who is Participating?
 
BadotzConnect With a Mentor Commented:
Nope - that is up to the browser.
0
 
leakim971Connect With a Mentor PluritechnicianCommented:
0
 
Paul JacksonConnect With a Mentor Software EngineerCommented:
Use
ONCLICK=window.open("www.google.com","_blank","")

whether this opens in a new tab or window is dependent on the user's browser preferences
0
 
rivkamakAuthor Commented:
If I use a regular a link. Can I specify a new tab versus new window?
0
 
BadotzCommented:
No worries - glad to help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.