0

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.

7
  • Have you tried use window.open instead of self.location? Commented Jul 5, 2013 at 16:39
  • check this: jsbin.com/ocoqid/1 Commented Jul 5, 2013 at 16:40
  • Try <input type="button" value="Latest Results" onClick="window.open('http://URL.COM/SEARCH STRING'+document.getElementById('code').value +'EXTRA BIT OF SEARCH URL', '_blank')"> Commented Jul 5, 2013 at 16:41
  • @PiLHA window.open as its second parameter has default _blank :P Commented Jul 5, 2013 at 16:42
  • @PiLHA check this: w3schools.com/jsref/met_win_open.asp Commented Jul 5, 2013 at 16:43

1 Answer 1

1

Try this:

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

Use window.open instead of self.location :)

jsBin.

Sign up to request clarification or add additional context in comments.

4 Comments

You should use JSfiddle instead of jsBin... it has a much nicer interface, so that the OP can see what is actually going on
@pattyd it have! let me give you an example difference :)
ah- I didn't try window.open and brackets. That's what I wanted- thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.