Trouver une ressource (Nouvelle version du moteur, plus rapide & pertinent, essayez le !)
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
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
Historique
- 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
Sources de la même categorie
Commentaires
Discussions en rapport avec ce code source
|
CalendriCode
| | | L | M | M | J | V | S | D |
| | | | | 1 | 2 | 3 |
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
|
Téléchargements
Logiciels à télécharger sur le même thème :
|