4 Replies Latest reply on Apr 7, 2014 10:13 AM by taramariemortensen

    Google Search bar

    taramariemortensen

      Hi everyone,

       

      I am designing a widget that will have a Google search bar at the top of the page (see picture).  The question is: How do I actually get this Google Search bar into my document? I found some code for the search bar at Google Free, but do I need an iframe code?

       

      Thanks.

       

      Tara MortensenScreen Shot 2014-04-06 at 1.06.59 PM.png

        • 1. Re: Google Search bar
          hemanthR Adobe Employee

          Does Google Free generate some embeddable iframe like the youtube?

          • 2. Re: Google Search bar
            taramariemortensen Level 1

            It doesn't seem to. And I'm not much of a coder, so I don't know how to generate the iframe code myself.  Anyone else?

             

            Tara

            • 3. Re: Google Search bar
              hemanthR Adobe Employee

              OK did some digging.

              this is what you get from Google when you click on 'Get Code'

              <script>

                (function() {

                  var cx = '<SOME UNIQUE CODE HERE>';

                  var gcse = document.createElement('script');

                  gcse.type = 'text/javascript';

                  gcse.async = true;

                  gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +

                      '//www.google.com/cse/cse.js?cx=' + cx;

                  var s = document.getElementsByTagName('script')[0];

                  s.parentNode.insertBefore(gcse, s);

                })();

              </script>

              <gcse:search></gcse:search>

               

              To add this to Aniamte:

              In he 'composition ready' add this modfied snippet

              sym.$("Rectangle").append("<gcse:search></gcse:search>");

               

               

              (function() {

                  var cx = '<SOME UNIQUE CODE HERE>';

                  var gcse = document.createElement('script');

                  gcse.type = 'text/javascript';

                  gcse.async = true;

                  gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +

                      '//www.google.com/cse/cse.js?cx=' + cx;

                  var s = document.getElementsByTagName('script')[0];

                  s.parentNode.insertBefore(gcse, s);

              })();

               

               

              Here i first append the google tag to my 'Rectangle' on stage than i run the function from the above code generated by google.

               

              Hope this helps.

              • 4. Re: Google Search bar
                taramariemortensen Level 1

                I'm going to give this a try.

                 

                Thank you!