Results 1 to 3 of 3

Thread: How to target results in new tab or window

  1. #1
    Join Date
    Apr 2017
    Thanked 0 Times in 0 Posts

    Cool How to target results in new tab or window


    Newbie here.

    I was working with this script and would like the results to be targeted to a new window or tab and not quite sure how to go about it.

    <form name="jksearch" action="" method="get" onSubmit="jksitesearch(this)">
    <p>Search JavaScript Kit:<br />
    <input id="hiddenquery" type="hidden" name="q" />
    <input name="qfront" type="text" style="width: 200px" value="navigator object" /> <input type="submit" value="Search" /><br />
    <div style="font: bold 11px Verdana;">Google:<input name="se" type="radio" checked>  Yahoo:<input name="se" type="radio">  MSN:<input name="se" type="radio">
    <script type="text/javascript">
    // All-in-one Internal Site Search script- By (
    // For this and over 400+ free scripts, visit JavaScript Kit -
    // This notice must stay intact for use
    //Enter domain of site to search.
    var domainroot=""
    var searchaction=[ //form action for the 3 search engines
    var queryfieldname=["q","p","q"] //name of hidden query form for the 3 search engines
    function switchaction(cur, index){
    function jksitesearch(curobj){
    for (i=0; i<; i++){ //loop through radio to see which is checked
    if ([i].checked==true)
    switchaction([i], i)
    document.getElementById("hiddenquery").value="site:"+domainroot+" "+curobj.qfront.value
    <p style="font: normal 11px Arial">This free script provided by<br />
    <a href="">JavaScript Kit</a></p>

    Last edited by jscheuer1; 04-29-2017 at 03:08 AM. Reason: format code

  2. #2
    Join Date
    Mar 2005
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries


    Add the highlighted:

    <form name="jksearch" action="" method="get" onSubmit="jksitesearch(this)" target="_blank">
    That will require a new window or (more likely, given today's browsers) tab, unless the user's browser has restrictions on pages opening new tabs (most do not). You can also use "_new" instead of "_blank", in which case the browser will reuse the existing new window (if any) from a previous search for subsequent searches (again, if any). However, if a previous window was opened by targeting "_new" for something else, it will be reused even for the initial search. Alternatively, you can try using an arbitrary and unique target value. As long as it's not in use by some other page in the user's browser and not reserved*, it will establish a tab for results that will be reused only for results.

    Any questions, or problems, feel free to ask.

    The browser cache may need to be cleared and/or the page refreshed to see changes.

    NOTE: Though you didn't ask, it might be tempting try to target an iframe or frame. However, Google for sure (last I checked), and probably most other search engines as well, has or likely will have restrictions that prevent that.

    *Some names are reserved and cannot be used for window/tab names.
    - John

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2017
    Thanked 0 Times in 0 Posts


    Hi John,

    thanks for the help. Worked like a charm!


Similar Threads

  1. Target=“_blank” vs
    By Rain Lover in forum HTML
    Replies: 3
    Last Post: 07-30-2014, 03:08 PM
  2. maximizing target window size
    By gib65 in forum HTML
    Replies: 1
    Last Post: 10-16-2009, 10:44 PM
  3. Target URL with window.print?
    By JBottero in forum JavaScript
    Replies: 0
    Last Post: 05-13-2009, 02:38 AM
  4. Carousel II (2) Open Target in SAME window
    By npimpfellow in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 05-01-2009, 03:36 AM
  5. Specify target window size without Javascript?
    By Eternal_Howl in forum HTML
    Replies: 4
    Last Post: 07-28-2007, 05:28 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts