Rob
Rob

Reputation: 51

HTML Input Button

I'm using this code here:

<input type="button"  value="Latest Results" onClick="self.location='http://URL.COM/SEARCH STRING'+document.getElementById('code').value +'EXTRA BIT OF SEARCH URL'">

Which I'm using with an input box (sometime several input boxes) to take an input and quickly add it to a URL to search an internal system. It works great for what we need, but I'm trying to get it to open in a new window rather than the current one.

I've tried adding target="_blank" to the end and changing onClick="self.location= to window.open but no luck.

Upvotes: 0

Views: 211

Answers (1)

Mohammad Areeb Siddiqui
Mohammad Areeb Siddiqui

Reputation: 10189

Try this:

<input type="button"  value="Latest Results" onClick="window.open('http://www.google.com');">

Use window.open instead of self.location :)

jsBin.

Upvotes: 1

Related Questions