Results 1 to 4 of 4

Thread: How to make the below code for a google search engine open in a new browser tab

  1. #1
    Join Date
    Jan 2010
    Location
    Tulsa, OK
    Posts
    49
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default How to make the below code for a google search engine open in a new browser tab

    Code:
    <script async src="https://cse.google.com/cse.js?cx=765fafd9751a049f3">
    </script>
    <div class="gcse-search"></div>
    Thank you.
    Last edited by james438; 03-08-2023 at 02:20 AM. Reason: format

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    2,457
    Thanks
    5
    Thanked 292 Times in 285 Posts

    Default

    Hi there Tedah3143,


    you need to have two files, the first linking to the second, like this...

    1. open-google-search.html
      Code:
      <!DOCTYPE HTML>
      <html lang="en">
      <head>
      
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">
      
      <title>Open Google Search</title>
      
      <link rel="stylesheet" href="screen.css" media="screen">
      
      </head>
      
      <body>
      
       <a href="google-search.html" target="blank">open "Google Search" in new window</a>
       
      </body>
      </html>
    2. google-search.html
      Code:
      <!DOCTYPE HTML>
      <html lang="en">
      <head>
      
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">
      
      <title>Google Search</title>
      
      </head>
      <body>
      
        <div class="gcse-search"></div>
      
        <script async src="https://cse.google.com/cse.js?cx=765fafd9751a049f3"></script> 
      
      </body>
      </html>

    Obviously, these are just basic files and both may have any amount of extra content.

    coothead
    ~ the original bald headed old fart ~

  3. #3
    Join Date
    Oct 2022
    Posts
    18
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default

    To make the Google search engine code open in a new browser tab, you can add a target attribute to the anchor tag in the generated code. Here's an example:


    Code:
    <script async src="https://cse.google.com/cse.js?cx=765fafd9751a049f3"></script>
    <div class="gcse-search">
      <a href="https://www.google.com/cse?q=query" target="_blank"></a>
    </div>
    In the above code, replace "https://www.google.com/cse?q=query" with the appropriate search URL you want to use. When someone clicks on the search button, it will open the search results in a new browser tab due to the target="_blank" attribute.
    Last edited by james438; 05-31-2023 at 02:31 AM. Reason: format

  4. #4
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    2,457
    Thanks
    5
    Thanked 292 Times in 285 Posts

    Default

    Hi there Finacustech,

    your suggested link...
    Code:
    <a href="https://www.google.com/cse?q=query" target="_blank"></a>
    ...will definitely take one to a new tab but this will, unfortunately, be the result...
    .
    https://programmablesearchengine.google.com/about/

    What the O.P actually wants is to be taken to a new tab that looks like this...

    Click image for larger version. 

Name:	Enhanced-by-google.png 
Views:	4 
Size:	5.7 KB 
ID:	6590

    I assume that you did not fully read the question.

    coothead
    ~ the original bald headed old fart ~

Similar Threads

  1. how make your pro search engine by using google as aol
    By Basim in forum Looking for such a script or service
    Replies: 2
    Last Post: 11-03-2007, 02:57 AM
  2. Keywords for google search engine.
    By Ty Sovanmony in forum HTML
    Replies: 3
    Last Post: 06-28-2007, 10:52 AM
  3. Search engine code
    By Skinnybobb in forum HTML
    Replies: 0
    Last Post: 11-08-2006, 11:54 AM
  4. Search Engine Code?
    By Sabis in forum Other
    Replies: 8
    Last Post: 08-21-2006, 08:39 AM
  5. how to make a search engine
    By newpupil1 in forum HTML
    Replies: 1
    Last Post: 09-03-2005, 10:58 AM

Bookmarks

Posting Permissions

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