begin process at 2008 08 28 21:41:54
1 233 393 membres
485 nouveaux aujourd'hui
14 291 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

MOTEUR DE RECHERCHE GOOGLE SUR SON SITE EN DEUX MINUTES - RÉSULTATS À L'INTÉRIEUR DE SON SITE


Information sur la source

Catégorie :Divers Classé sous : recherche, google, search, cherche Niveau : Débutant Date de création : 13/07/2007 Date de mise à jour : 23/07/2007 17:43:49 Vu : 11 675

Note :
1 / 10 - par 2 personnes
1,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (10)
Ajouter un commentaire et/ou une note

Description

Voici une technique pour avoir un moteur de recherche google sur son propre site avec affichage des résultats à l'intérieur de son site.

Voir un exemple de ce que l'on peut faire avec ce script : http://gootube.mezy.fr

Les résultats se chargent en javascript.

Pour modifier la largeur de l'affichage des résultats changer la valeur de la variable googleSearchFrameWidth. Attention les pourcentage ne sont pas acceptés.

La deuxième partie du code peut être mis dans une autre page pour afficher les résultats dans une autre page. Dans ce cas changer la valeur de l'attribut action.

Source

  • <!-- 1ere partie //-->
  • <form id="searchbox_016444025208201823482:cdrnkgva6vm" action="">
  • <input type="hidden" name="cx" value="016444025208201823482:cdrnkgva6vm" />
  • <input type="hidden" name="cof" value="FORID:9" />
  • <input name="q" type="text" size="40" />
  • <input type="submit" name="sa" value="Recherche" />
  • </form>
  • <!-- 2eme partie //-->
  • <div id="results_016444025208201823482:cdrnkgva6vm"></div>
  • <script type="text/javascript">
  • var googleSearchIframeName = "results_016444025208201823482:cdrnkgva6vm";
  • var googleSearchFormName = "searchbox_016444025208201823482:cdrnkgva6vm";
  • var googleSearchFrameWidth = 600;
  • var googleSearchFrameborder = 0;
  • var googleSearchDomain = "www.google.fr";
  • var googleSearchPath = "/cse";
  • (function(){var f=null,a=window,j="sitesearch",s=a.googleSearchResizeIframe||a.googleSearchPath&&a.googleSearchPath=="/cse"&&typeof a.googleSearchResizeIframe=="undefined",p,o,k;function t(c,b,l,m){var d={},g=c.split(l);for(var e=0;e<g.length;e++){var h=g[e],n=h.indexOf(b);if(n>0){var i=h.substring(0,n);if(m){i=i.toUpperCase()}else{i=i.toLowerCase()}var w=h.substring(n+1,h.length);d[i]=w}}return d}function x(){var c=document.location.search;if(c.length<1){return""}c=c.substring(1,c.length);var b=
  • t(c,"=","&",false);if(a.googleSearchQueryString!="q"&&b[a.googleSearchQueryString]){b.q=b[a.googleSearchQueryString];delete b[a.googleSearchQueryString]}if(b.cof){var l=t(decodeURIComponent(b.cof),":",";",true),m=l.FORID;if(m){p=parseInt(m,10)}}var d=document.getElementById(a.googleSearchFormName);if(d){if(d.q&&b.q&&(!b.ie||b.ie.toLowerCase()=="utf-8")){d.q.value=decodeURIComponent(b.q.replace(/\+/g," "))}if(d[j]){for(var g=0;g<d[j].length;g++){if(b[j]==f&&d[j][g].value==""){d[j][g].checked=true}else if(d[j][g].value==
  • b[j]){d[j][g].checked=true}else{d[j][g].checked=false}}}}var e="";for(var h in b){e+="&"+h+"="+b[h]}return e.substring(1,e.length)}function q(c,b){if(b){return"&"+c+"="+encodeURIComponent(b)}else{return""}}function r(c,b){if(c){return Math.max(c,b)}else{return b}}function u(){var c="http://";if(a.googleSearchDomain){c+=a.googleSearchDomain}else{c+="www.google.com"}if(a.googleSearchPath){c+=a.googleSearchPath}else{c+="/custom"}c+="?";if(a.googleSearchQueryString){a.googleSearchQueryString=a.googleSearchQueryString.toLowerCase()}c+=
  • x();c+=q("ad","w"+o);c+=q("num",k);c+=q("adtest",a.googleAdtest);if(s){var b=a.location.href,l=b.indexOf("#");if(l!=-1){b=b.substring(0,l)}c+=q("rurl",b)}return c}function v(){o=a.googleSearchNumAds;if(!o){o=9}k=a.googleNumSearchResults;if(k){k=Math.min(k,20)}else{k=10}var c={};c[9]=795;c[10]=795;c[11]=500;var b={};b[9]=300+90*k;b[10]=300+50*Math.min(o,4)+90*k;b[11]=300+50*o+90*k;var l=u();if(!a.googleSearchFrameborder){a.googleSearchFrameborder="0"}var m=document.getElementById(a.googleSearchIframeName);
  • if(m&&c[p]){var d=r(a.googleSearchFrameWidth,c[p]),g=r(a.googleSearchFrameHeight,b[p]),e=document.createElement("iframe"),h={name:"googleSearchFrame",src:l,frameBorder:a.googleSearchFrameborder,width:d,height:g,marginWidth:"0",marginHeight:"0",hspace:"0",vspace:"0",allowTransparency:"true",scrolling:"no"};for(var n in h){e.setAttribute(n,h[n])}m.appendChild(e);if(e.attachEvent){e.attachEvent("onload",function(i){window.scrollTo(0,0)})}else{e.addEventListener("load",function(){window.scrollTo(0,0)},
  • false)}if(s){a.setInterval(function(){if(a.location.hash&&a.location.hash!="#"){var i=a.location.hash.substring(1)+"px";if(e.height!=i&&i!="0px"){e.height=i}}},10)}}a.googleSearchIframeName=f;a.googleSearchFormName=f;a.googleSearchResizeIframe=f;a.googleSearchQueryString=f;a.googleSearchDomain=f;a.googleSearchPath=f;a.googleSearchFrameborder=f;a.googleSearchFrameWidth=f;a.googleSearchFrameHeight=f;a.googleSearchNumAds=f;a.googleNumSearchResults=f;a.googleAdtest=f}v()})();
  • </script>
  <!-- 1ere partie //-->
  <form id="searchbox_016444025208201823482:cdrnkgva6vm" action="">
    <input type="hidden" name="cx" value="016444025208201823482:cdrnkgva6vm" />
    <input type="hidden" name="cof" value="FORID:9" />
    <input name="q" type="text" size="40" />
    <input type="submit" name="sa" value="Recherche" />
  </form>

  <!-- 2eme partie //-->
  <div id="results_016444025208201823482:cdrnkgva6vm"></div>
  <script type="text/javascript">
    var googleSearchIframeName 	= "results_016444025208201823482:cdrnkgva6vm";
    var googleSearchFormName 	= "searchbox_016444025208201823482:cdrnkgva6vm";
    var googleSearchFrameWidth 	= 600;
    var googleSearchFrameborder = 0;
    var googleSearchDomain 		= "www.google.fr";
    var googleSearchPath 		= "/cse";
	
(function(){var f=null,a=window,j="sitesearch",s=a.googleSearchResizeIframe||a.googleSearchPath&&a.googleSearchPath=="/cse"&&typeof a.googleSearchResizeIframe=="undefined",p,o,k;function t(c,b,l,m){var d={},g=c.split(l);for(var e=0;e<g.length;e++){var h=g[e],n=h.indexOf(b);if(n>0){var i=h.substring(0,n);if(m){i=i.toUpperCase()}else{i=i.toLowerCase()}var w=h.substring(n+1,h.length);d[i]=w}}return d}function x(){var c=document.location.search;if(c.length<1){return""}c=c.substring(1,c.length);var b=
t(c,"=","&",false);if(a.googleSearchQueryString!="q"&&b[a.googleSearchQueryString]){b.q=b[a.googleSearchQueryString];delete b[a.googleSearchQueryString]}if(b.cof){var l=t(decodeURIComponent(b.cof),":",";",true),m=l.FORID;if(m){p=parseInt(m,10)}}var d=document.getElementById(a.googleSearchFormName);if(d){if(d.q&&b.q&&(!b.ie||b.ie.toLowerCase()=="utf-8")){d.q.value=decodeURIComponent(b.q.replace(/\+/g," "))}if(d[j]){for(var g=0;g<d[j].length;g++){if(b[j]==f&&d[j][g].value==""){d[j][g].checked=true}else if(d[j][g].value==
b[j]){d[j][g].checked=true}else{d[j][g].checked=false}}}}var e="";for(var h in b){e+="&"+h+"="+b[h]}return e.substring(1,e.length)}function q(c,b){if(b){return"&"+c+"="+encodeURIComponent(b)}else{return""}}function r(c,b){if(c){return Math.max(c,b)}else{return b}}function u(){var c="http://";if(a.googleSearchDomain){c+=a.googleSearchDomain}else{c+="www.google.com"}if(a.googleSearchPath){c+=a.googleSearchPath}else{c+="/custom"}c+="?";if(a.googleSearchQueryString){a.googleSearchQueryString=a.googleSearchQueryString.toLowerCase()}c+=
x();c+=q("ad","w"+o);c+=q("num",k);c+=q("adtest",a.googleAdtest);if(s){var b=a.location.href,l=b.indexOf("#");if(l!=-1){b=b.substring(0,l)}c+=q("rurl",b)}return c}function v(){o=a.googleSearchNumAds;if(!o){o=9}k=a.googleNumSearchResults;if(k){k=Math.min(k,20)}else{k=10}var c={};c[9]=795;c[10]=795;c[11]=500;var b={};b[9]=300+90*k;b[10]=300+50*Math.min(o,4)+90*k;b[11]=300+50*o+90*k;var l=u();if(!a.googleSearchFrameborder){a.googleSearchFrameborder="0"}var m=document.getElementById(a.googleSearchIframeName);
if(m&&c[p]){var d=r(a.googleSearchFrameWidth,c[p]),g=r(a.googleSearchFrameHeight,b[p]),e=document.createElement("iframe"),h={name:"googleSearchFrame",src:l,frameBorder:a.googleSearchFrameborder,width:d,height:g,marginWidth:"0",marginHeight:"0",hspace:"0",vspace:"0",allowTransparency:"true",scrolling:"no"};for(var n in h){e.setAttribute(n,h[n])}m.appendChild(e);if(e.attachEvent){e.attachEvent("onload",function(i){window.scrollTo(0,0)})}else{e.addEventListener("load",function(){window.scrollTo(0,0)},
false)}if(s){a.setInterval(function(){if(a.location.hash&&a.location.hash!="#"){var i=a.location.hash.substring(1)+"px";if(e.height!=i&&i!="0px"){e.height=i}}},10)}}a.googleSearchIframeName=f;a.googleSearchFormName=f;a.googleSearchResizeIframe=f;a.googleSearchQueryString=f;a.googleSearchDomain=f;a.googleSearchPath=f;a.googleSearchFrameborder=f;a.googleSearchFrameWidth=f;a.googleSearchFrameHeight=f;a.googleSearchNumAds=f;a.googleNumSearchResults=f;a.googleAdtest=f}v()})();

  </script>

Conclusion

J'espere que ça vous sera utile. En tous cas c'est rapide et simple à mettre en place.

Pour insérer un plan d'accés Google Maps sur son site voir mon tutoriel : http://www.javascriptfr.com/tutoriaux/PLAN-ACCES-SUR-VOTRE-SITE-AVEC-ZOOM-VUE_705.aspx
13 juillet 2007 01:04:11 :
Ajout d'une note de fin ;)
13 juillet 2007 01:06:18 :
Test ajout de lien
13 juillet 2007 01:07:33 :
L'insertion de lien ne marche pas->suppression du href
23 juillet 2007 17:43:50 :
Voir un exemple de ce que l'on peut faire avec ce script : http://gootube.mezy.fr
  • signaler à un administrateur
    Commentaire de bultez le 13/07/2007 12:06:25


    si tu voulais que ton script soit illisible
    et totalement inexploitable pour un débutant :
    c'est réussi. franchement, c'est horrible.

    perso, je préfère utiliser, bêtement le formulaire,
    et si on s'inscrit sur google, en ajoutant quelques lignes
    au formulaire ( mais tout est fourni ! ) on peut même gagner des sous...

    <form method="get"
    action="http://www.google.fr/custom"
    target="_top" >
    <input type="text" name="q" size="32" maxlength="255"
    value="" id="sbi"></input><br />
    <input type="radio" class="checkbox" name="sitesearch"
    value="" checked id="ss0"></input>
    <label for="ss0" title="Rechercher sur le Web">sur le Web</label>
    <input type="radio" class="checkbox" name="sitesearch"
    value="marcel-bultez.chez-alice.fr" id="ss1"></input>
    <label for="ss1" title="Rechercher sur ce site">sur ce site</label><br />
    <input type="submit" />
    </form>

  • signaler à un administrateur
    Commentaire de bultez le 13/07/2007 13:02:55

    j'ai omis de dire que pour mettre le résultat
    là où l'on veut : target est fait pour ça.
    du style :
    <form ...target="r"...>
    ...
    </form>
    <iframe id=="r" name="r"></iframe>

  • signaler à un administrateur
    Commentaire de yodjii le 13/07/2007 19:51:54

    Merci pour ces infos supplémentaires. Pour moi c'est simple, pour un débutant il lui suffit de faire un copier coller et ca fonctionne.

    D'autre part avec ta technique si tu n'utilises pas le target tu es redirigé vers une page à l'extérieur de ton site. Ce qui n'est pas forcément souhaitable si tu veux garder tes visiteurs.
    Et si tu utilise le target avec l'iframe pour que les résultats apparaissent dans la même page tu te retrouve avec deux  fois le moteur de recherche! Le tiens plus celui généré par google dans la iframe... Avec le script que je propose ce n'est pas le cas.

  • signaler à un administrateur
    Commentaire de bultez le 14/07/2007 12:33:37


    >>si tu n'utilises pas le target tu es redirigé vers une page à l'extérieur
    c'est peut-être ce qui est voulu ? sinon, suffit de le mettre.

    >>tu te retrouve avec deux  fois le moteur de recherche
    si ça gène, suffit de l'effacer, non ?

    >>Avec le script que je propose
    mon reproche est qu'il est totalement illisible.
    en plus d'être lourd... pour remplacer un simple
    formulaire qui fait la même chose ( et qui
    pourrait faire plus )

    @+

  • signaler à un administrateur
    Commentaire de yodjii le 23/07/2007 17:46:19

    J'ai rajouté un exemple de ce que l'on peut faire avec ce script : http://gootube.mezy.fr

  • signaler à un administrateur
    Commentaire de olive028 le 31/07/2007 12:10:03

    bjr,
    A quoi correspond ce code: 016444025208201823482:cdrnkgva6vm  ?
    merci.

  • signaler à un administrateur
    Commentaire de yodjii le 02/08/2007 14:30:21

    Il s'agit d'un id de moteur fourni par Google

  • signaler à un administrateur
    Commentaire de XtremDuke le 08/08/2007 15:03:59

    Mouai +1 pour Bultez...

  • signaler à un administrateur
    Commentaire de R3dDragon le 28/01/2008 17:26:34 1/10

    Je peut me planter mais ce code me rappelle quelque chose...

    As-tu inventé ce code, ou juste copier certaines informations de Google???

  • signaler à un administrateur
    Commentaire de smed79 le 02/07/2008 20:08:37

    je vous propose ça:

    [img]http://www.farspic.com/files/vcx4798hbaqswlfyjmz7.jpg[/img]

    [code]<form action="http://www.google.fr/cse" id="cse-search-box" target="_blank">
      <div>
        <input type="hidden" name="cx" value="partner-pub-4340418046855073:ce3sfx-5ixy" />
        <input type="hidden" name="ie" value="ISO-8859-1" />
        <input type="text" name="q" size="24" />
        <input type="submit" name="sa" value="Rechercher" />
      </div>
    </form>
    <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=fr"></script>[/code]

Ajouter un commentaire

Pub



Appels d'offres

Recherche developpeur ...
Budget : 700€
SITE MARCHAND LOCATION...
Budget : 3 000€
SITE MARCHAND POUR HOTEL
Budget : 4 000€

CalendriCode

Août 2008
LMMJVSD
    123
45678910
11121314151617
18192021222324
25262728293031

Téléchargements

Boutique

Boutique de goodies CodeS-SourceS