[98] Protection d'un répertoire
Depuis Windows 98 il est possible de personnaliser l'apparence d'un dossier. Ce qui se cache derrière cette personnalisation est en fait un joli code HTML et ... JAVASCRIPT.
Il est donc aisé d'y introduire un code demandant un mot de passe et n'autorisant l'accès à la fenêtre du dossier que si le mot de passe est correct.
Étapes de création
1. Prenez un dossier au hasard et faites un clic droit là où il n'y a pas d'icone
2. Choisissez 'Personnaliser ce dossier' puis 'Choisir ou modifier un modèle HTML pour ce dossier'
3. Prenez le modèle qui vous plait et cliquez sur la case 'Modifier ce modèle'
4. Mettez onload="CheckPassword();" dans l'ouverture de la balise BODY
5. Entrez ce code dans le fichier en début de fichier par exemple :
<script language=JScript>
var pass="";
var child;
function CheckPassword()
{
document.body.style.visibility="hidden";
child=window.open("", "", "menubar=no,alwaysRaised=yes,resizable=no,scrollbars=no,status=no,width=250,height=100");
child.document.open();
child.document.write("<html><head><title>Mot de passe requis</title><sc");
child.document.write("cript language=javascript></scr");
child.document.write("ipt><scri");
child.document.write("pt>function nop() { return false; }</scri");
child.document.write("pt><scr");
child.document.write("ipt>function login() { window.opener.pass='.'+pwd.value; } </scri");
child.document.write("pt></head><style>body { font-family: Tahoma; font-size: 9pt; font-weight:bold; color: #333399; } input { font-family: Tahoma; font-size: 8pt; color: #993333; }</style>");
child.document.write("<body bgcolor=#e0e0e0 onUnLoad='bye();'><center>Entrez le mot de passe :<br><input type='password' name='pwd' size='20' value='undefined'><br><br><input type='button' value=' Login ' onClick='login();' style='color=#228822'></p></body><sc");
child.document.write("ript language=JScript>document.oncontextmenu=nop; document.body.onclick=nop;</scri");
child.document.write("pt></html>");
setTimeout("GetPwd()", 150);
}
function GetPwd()
{
if(pass=="")
setTimeout("GetPwd()", 150);
else
{
child.close();
if(pass!=".OpenMe")
{
window.location="C:";
return false;
}
else
{
document.body.style.visibility="visible";
return true;
}
}
return false;
}
</script>
Trouvé sur http://www.javascriptfr.com
Retour à la liste des sujets
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 29/10/2003, last modified the 03/02/2021
Source of the printed document:https://www.gaudry.be/en/astuces-rf-9.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
- Forum :
Contexte original : https://www.gaudry.be/en/forum/viewtopic.php?t=194
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.