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 !

AFFICHER ADRESSE PAGE D'ACCUEIL


Information sur la source

Description

Ceci est petit script pas génial mais qui est très serviable dans les erreurs 404
En fait c'est une page 404 avec un lien vers la page d'accueil
en fait il affiche l'adresse de la page d'accueil du site en lien.
 

Source

  • <php
  • include "zip, zip, zip";
  • ?>
  • merci de prendre le zip mais si c'est vraiment non :
  • Mais vous pouvez suivre le code ici :
  • Avec . htaccess
  • ----------------
  • .htaccess :
  • ErreurDocument 404 erreur404.html
  • erreur404.html :
  • <html>
  • <head>
  • <script>
  • function Homepage(){
  • <!--
  • // in real bits, urls get returned to our script like this:
  • // res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm
  • //For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm"
  • DocURL = document.URL;
  • //this is where the http or https will be, as found by searching for :// but skipping the res://
  • protocolIndex=DocURL.indexOf("://",4);
  • //this finds the ending slash for the domain server
  • serverIndex=DocURL.indexOf("/",protocolIndex + 3);
  • //for the href, we need a valid URL to the domain. We search for the # symbol to find the begining
  • //of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.
  • //urlresult=DocURL.substring(protocolIndex - 4,serverIndex);
  • BeginURL=DocURL.indexOf("#",1) + 1;
  • urlresult=DocURL.substring(BeginURL,serverIndex);
  • //for display, we need to skip after http://, and go to the next slash
  • displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);
  • InsertElementAnchor(urlresult, displayresult);
  • }
  • function HtmlEncode(text)
  • {
  • return text.replace(/&/g, '&amp').replace(/'/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  • }
  • function TagAttrib(name, value)
  • {
  • return ' '+name+'="'+HtmlEncode(value)+'"';
  • }
  • function PrintTag(tagName, needCloseTag, attrib, inner){
  • document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) );
  • if (needCloseTag) document.write( '</' + tagName +'>' );
  • }
  • function URI(href)
  • {
  • IEVer = window.navigator.appVersion;
  • IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 );
  • return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ?
  • encodeURI(href) :
  • escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');
  • }
  • function InsertElementAnchor(href, text)
  • {
  • PrintTag('A', true, TagAttrib('HREF', URI(href)), text);
  • }
  • //-->
  • </script>
  • </head>
  • <body>
  • <p align="center"><font color="#FF0000"><h1><u>404 not found</u></h1></font></p><br>// écrire 404 not found
  • <p align="left"><font color="#FF0000"><h2>La page est introuvable</h2></font></p><br><br>
  • <span style="color: #ff0000">La page d'accueil de ce site est <script>
  • <!--
  • if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2")))page
  • {
  • Homepage();
  • }
  • //-->
  • </script>
  • <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  • <p align="left"><font color="#FF0000"><h7>Affichage de la page d'accueil sans .htaccess Code écrit par Cédric Denotte</h7></font><br>
  • <font color="#FF0000"><h7>Copyright 26/12/2006</h7></font><br>
  • <font color="#FF0000"><h7><a href="http://www.cdd-pro.com">http://www.cdd-pro.com</a> | <a href="mailto:cdd@cdd-pro.com">cdd@cdd-pro.com</a></h7></font><br>
  • <font color="#FF0000"><h7>E-mail et site web valide à partir du 28/12/2006 Sinon <a href="mailto:cedric_denotte@msn.com">cedric_denotte@msn.com</a></h7></font></p>
  • </body>
  • </html>
  • -------------------------------------------------------------------------------------------------------------------------
  • Sans .htaccess
  • ---------------
  • index.html :
  • <html>
  • <head>
  • <script>
  • function Homepage(){
  • <!--
  • // in real bits, urls get returned to our script like this:
  • // res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm
  • //For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm"
  • DocURL = document.URL;
  • //this is where the http or https will be, as found by searching for :// but skipping the res://
  • protocolIndex=DocURL.indexOf("://",4);
  • //this finds the ending slash for the domain server
  • serverIndex=DocURL.indexOf("/",protocolIndex + 3);
  • //for the href, we need a valid URL to the domain. We search for the # symbol to find the begining
  • //of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.
  • //urlresult=DocURL.substring(protocolIndex - 4,serverIndex);
  • BeginURL=DocURL.indexOf("#",1) + 1;
  • urlresult=DocURL.substring(BeginURL,serverIndex);
  • //for display, we need to skip after http://, and go to the next slash
  • displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);
  • InsertElementAnchor(urlresult, displayresult);
  • }
  • function HtmlEncode(text)
  • {
  • return text.replace(/&/g, '&amp').replace(/'/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  • }
  • function TagAttrib(name, value)
  • {
  • return ' '+name+'="'+HtmlEncode(value)+'"';
  • }
  • function PrintTag(tagName, needCloseTag, attrib, inner){
  • document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) );
  • if (needCloseTag) document.write( '</' + tagName +'>' );
  • }
  • function URI(href)
  • {
  • IEVer = window.navigator.appVersion;
  • IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 );
  • return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ?
  • encodeURI(href) :
  • escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');
  • }
  • function InsertElementAnchor(href, text)
  • {
  • PrintTag('A', true, TagAttrib('HREF', URI(href)), text);
  • }
  • //-->
  • </script>
  • </head>
  • <body>
  • <span style="color: #ff0000">La page d'accueil de ce site est <script>
  • <!--
  • if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2")))
  • {
  • Homepage();
  • }
  • //-->
  • </script>
  • <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  • <p align="left"><font color="#FF0000"><h7>Affichage de la page d'accueil sans .htaccess Code écrit par Cédric Denotte</h7></font><br>
  • <font color="#FF0000"><h7>Copyright 26/12/2006</h7></font><br>
  • <font color="#FF0000"><h7><a href="http://www.cdd-pro.com">http://www.cdd-pro.com</a> | <a href="mailto:cdd@cdd-pro.com">cdd@cdd-pro.com</a></h7></font><br>
  • <font color="#FF0000"><h7>E-mail et site web valide à partir du 28/12/2006 Sinon <a href="mailto:cedric_denotte@msn.com">cedric_denotte@msn.com</a></h7></font></p>
  • </body>
  • </html>
  • -------------------------------------------------------------------------------------------------------------------------
  • Merci plutot de télécharger le zip
<php
   include "zip, zip, zip";
?>

merci de prendre le zip mais si c'est vraiment non :

Mais vous pouvez suivre le code ici :
Avec . htaccess
----------------
.htaccess :

ErreurDocument 404 erreur404.html

erreur404.html :

<html>
 <head>
<script> 

function Homepage(){

<!--

// in real bits, urls get returned to our script like this:

// res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm 



	//For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm"

	DocURL = document.URL;

		

	//this is where the http or https will be, as found by searching for :// but skipping the res://

	protocolIndex=DocURL.indexOf("://",4);

	

	//this finds the ending slash for the domain server 

	serverIndex=DocURL.indexOf("/",protocolIndex + 3);



		//for the href, we need a valid URL to the domain. We search for the # symbol to find the begining 

	//of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.

	//urlresult=DocURL.substring(protocolIndex - 4,serverIndex);

	BeginURL=DocURL.indexOf("#",1) + 1;

	

	urlresult=DocURL.substring(BeginURL,serverIndex);

				

	//for display, we need to skip after http://, and go to the next slash

	displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);



	InsertElementAnchor(urlresult, displayresult);

}


function HtmlEncode(text)
{
    return text.replace(/&/g, '&amp').replace(/'/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

function TagAttrib(name, value)
{
    return ' '+name+'="'+HtmlEncode(value)+'"';
}

function PrintTag(tagName, needCloseTag, attrib, inner){
    document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) );
    if (needCloseTag) document.write( '</' + tagName +'>' );
}

function URI(href)
{
    IEVer = window.navigator.appVersion;
    IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 );

    return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ?
        encodeURI(href) :
        escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');
}

function InsertElementAnchor(href, text)
{
    PrintTag('A', true, TagAttrib('HREF', URI(href)), text);
}

//-->

</script>

 </head>
 <body>
  <p align="center"><font color="#FF0000"><h1><u>404 not found</u></h1></font></p><br>// écrire 404 not found
  <p align="left"><font color="#FF0000"><h2>La page est introuvable</h2></font></p><br><br>
  <span style="color: #ff0000">La page d'accueil de ce site est  <script>

	  <!--

	  if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2")))page

	  { 

	  	Homepage();

	  }

	  //-->

	   </script>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p align="left"><font color="#FF0000"><h7>Affichage de la page d'accueil sans .htaccess Code écrit par Cédric Denotte</h7></font><br>
<font color="#FF0000"><h7>Copyright 26/12/2006</h7></font><br>
<font color="#FF0000"><h7><a href="http://www.cdd-pro.com">http://www.cdd-pro.com</a> | <a href="mailto:cdd@cdd-pro.com">cdd@cdd-pro.com</a></h7></font><br>
<font color="#FF0000"><h7>E-mail et site web valide à partir du 28/12/2006 Sinon <a href="mailto:cedric_denotte@msn.com">cedric_denotte@msn.com</a></h7></font></p>
</body>
</html>

-------------------------------------------------------------------------------------------------------------------------
Sans .htaccess
---------------

index.html :

<html>

 <head>
<script> 

function Homepage(){

<!--

// in real bits, urls get returned to our script like this:

// res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm 



	//For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm"

	DocURL = document.URL;

		

	//this is where the http or https will be, as found by searching for :// but skipping the res://

	protocolIndex=DocURL.indexOf("://",4);

	

	//this finds the ending slash for the domain server 

	serverIndex=DocURL.indexOf("/",protocolIndex + 3);



		//for the href, we need a valid URL to the domain. We search for the # symbol to find the begining 

	//of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.

	//urlresult=DocURL.substring(protocolIndex - 4,serverIndex);

	BeginURL=DocURL.indexOf("#",1) + 1;

	

	urlresult=DocURL.substring(BeginURL,serverIndex);

				

	//for display, we need to skip after http://, and go to the next slash

	displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);



	InsertElementAnchor(urlresult, displayresult);

}


function HtmlEncode(text)
{
    return text.replace(/&/g, '&amp').replace(/'/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

function TagAttrib(name, value)
{
    return ' '+name+'="'+HtmlEncode(value)+'"';
}

function PrintTag(tagName, needCloseTag, attrib, inner){
    document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) );
    if (needCloseTag) document.write( '</' + tagName +'>' );
}

function URI(href)
{
    IEVer = window.navigator.appVersion;
    IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 );

    return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ?
        encodeURI(href) :
        escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');
}

function InsertElementAnchor(href, text)
{
    PrintTag('A', true, TagAttrib('HREF', URI(href)), text);
}

//-->

</script>

 </head>
 <body>
  <span style="color: #ff0000">La page d'accueil de ce site est  <script>

	  <!--

	  if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2")))

	  { 

	  	Homepage();

	  }

	  //-->

	   </script>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p align="left"><font color="#FF0000"><h7>Affichage de la page d'accueil sans .htaccess Code écrit par Cédric Denotte</h7></font><br>
<font color="#FF0000"><h7>Copyright 26/12/2006</h7></font><br>
<font color="#FF0000"><h7><a href="http://www.cdd-pro.com">http://www.cdd-pro.com</a> | <a href="mailto:cdd@cdd-pro.com">cdd@cdd-pro.com</a></h7></font><br>
<font color="#FF0000"><h7>E-mail et site web valide à partir du 28/12/2006 Sinon <a href="mailto:cedric_denotte@msn.com">cedric_denotte@msn.com</a></h7></font></p>

</body>
</html>
-------------------------------------------------------------------------------------------------------------------------
Merci plutot de télécharger le zip 

Conclusion

Si je trouves des amériotations encore mieux je vous les envois tout de suite !!!
biento une adresse d'exemple.

~mon site~ http://www.cdd-pro.com
 

Fichier Zip

Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip

Commentaires et avis

signaler à un administrateur
Commentaire de Naixn le 28/12/2006 09:47:02

"En fait c'est une page 404 avec un lien vers la page d'accueil
en fait il affiche l'adresse de la page d'accueil du site en lien."
>> Jolie répétition

Sinon est-ce que c'est vraiment ton code ?

Ah et aussi :
// in real bits, urls get returned to our script like this:
// res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm
>> Bah c'est faux... Pas sous Linux ou Mac OS X par exemple...

signaler à un administrateur
Commentaire de astuces_jeux le 28/12/2006 10:12:24

Sur windows sa marche parfaitement !!!

signaler à un administrateur
Commentaire de Naixn le 28/12/2006 10:28:47

C'est bien ce que je dis :
ça marche sous Windows, mais pas ailleurs.

M'enfin... :)

signaler à un administrateur
Commentaire de astuces_jeux le 28/12/2006 11:44:23

sur windows sa put très bien servir dans les erreurs 404 !!!

signaler à un administrateur
Commentaire de mickaelpfr le 17/01/2007 17:16:54

ton script ne sert a rien !
tu insères ( enfin toi ... le script ... ) utilise un bout de code php ... autant récupéré le referer pour savoir d'ou l'on viens pour renvoyer a la page précédente ou tout simplement récupèrer l'url en php et coller un lien !
.bar pas besoins de javascript !
bonne journée :)

signaler à un administrateur
Commentaire de astuces_jeux le 18/01/2007 20:34:27

je cherche sa mais j'y arrive pas !! ta un exemple ???

signaler à un administrateur
Commentaire de astuces_jeux le 21/01/2007 19:22:29

bonjour,
j'ai réussis a faire une page d'erreur 404 génial qui marche avec le moteur de recherche sur le web que j'ai créer !!!
moteur recherche : http://search.cdd-pro.com
Voir page erreur 404 : http://www.cdd-pro.com/jdfshdsffdfuy
@++

Ajouter un commentaire

Discussions en rapport avec ce code source dans le forum

SOCKET pour suivre en temps réel la variation d'entrées logiques. [ par jlop ] Bonjour, je vraiment très débutant en javascript. J'aurais le besoin suivant: Un serveur WEB tourne sur une carte éléctronique gère par exemple des en Pb frame et affichage d'adresse [ par Amadeus ] La page index de mon site contient une FRAME :Dans index.htm, j'ai mis cela :&lt;FRAMESET COLS="24%,76%" BORDER="0"&gt;&lt;FRAME src="Liste.htm"&gt;&l detecter le changement d'adresse dans un frame [ par n3co ] Bonjour,est-ce que c'est possible de détecter, sur une page HTML contenant 2 frames, le changement de page sur l'un et le récupérer dans l'autre ?C'es Barre de progréssion durant le chargement d'un page [ par rem78 ] Bonjour,Je suis actuellement entraint de réaliser mon site et ma page d'accueil comporte des frames (cadres) et je souhaite la faire ouvrir en mode pl Dialogue entre frames: petit soucis [ par Tiscripteur ] J'ai un soucis que je n'arrive pas à résoudre:Je n'arrive pas à récupérer l'adresse de la frame qui m'héberge.Si elle se trouve sur le même serveur qu impression page web sans adresse [ par shaft107 ] slt a tousj'ai un pb,je voudrai imprimer une page web mais sans l'adresse de la page car ils'agit de l'imprimer sur un papier entetejavascript ou vb s Besoin d'aide pour créer un cookie [ par gproulx ] Bonjour à tous!J'ai un petit problème. Je dois créer un cookie, seulement j'ai jamais fait cela et n'étant que graphiste pour site web, la programmati envoi de mail avec lotus [ par katwes ] Bonjour,J'essaie d'envoyer une page par mail en cliquant sur un ic&#244;ne. Ca fonctionne avec outlook mais quand la messagerie est lotus, l'adresse d Changer de page sans changer l'adresse [ par astuces_jeux ] Bonjour, Je cherche comment faire pour cr&#233;er une page ou comme javascriptfr.comil y a des liens : derniers codes/tutoriaux/vid&#233;o/codes modif Apparition d'images [ par laubro ] Bonjour,je voudrais, pour une page d'accueil, compos&#233;e en fait de 4 images, formant un carr&#233; une fois r&#233;unis, avoir un effet faisant en


Nos sponsors

Sondage...

CalendriCode

Octobre 2008
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
2728293031  

Consulter la suite du CalendriCode

Téléchargements

Logiciels à télécharger sur le même thème :



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel BAÏSE, Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,234 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.