snippets / html

All snippets tagged html (6)

  1. PNG-fix pour ie6

    Usage: Si utilisé avec le mode "scale", il faut que l'élément qui le contient ait un height:100% pour que le height soit "computed", parce que le mode scale se fie au computed height (celui donné explicitement par le CSS).--- crop Clips the image to fit the dimensions of the object. image Default. Enlarges or reduces the border of the object to fit the dimensions of the image. scale Stretches or shrinks the image to fill the borders of the object.***

    1 <!--[if lt IE 7]> 
    2 <style>#logo{
    3 background:none;
    4 filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="fond.png", sizingMethod="scale");
    5 }</style>
    6 <![endif]-->
    Posted by juliend2 to css css html ie ie6 ... saved by 1 person ... 0 comments ... 7 months
  2. Ajax simple (pas IE6)

    Avec start/stop feature optionnel (pour un throbber) / Compatible "xmlhttprequet" (pas ie) / Prends en compte l'encoding et l'escaping / Envoi en POST, pour s'affranchir des probs de taille / url randomizé pour eviter cache / Système de paramètres via dico javascript / callback integré dans la declaration de la methode

     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    2 <html>
    3 <head>
    4 <meta http-equiv="content-type" content="text/html; charset=utf-8">
    5 <title></title>
    6 <style type='text/css'>
    7 </style>
    8 <script type='text/javascript'>
    9 function $(id) {return document.getElementById(id);}
    10
    11 function x_call(action, obj,callback) {
    12 var uri="ajax?action=" + escape(action); // server side
    13 uri+="&"+new Date().getTime();
    14
    15 var post_data = ""
    16 for (var i in obj)
    17 post_data = post_data + "&"+escape(i)+"=" + escape(obj[i]);
    18
    19 if(x_call.start) x_call.start();
    20
    21 var x = new XMLHttpRequest();
    22 x.open("POST", uri, true);
    23 x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
    24 x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
    25 x.onreadystatechange = function() {
    26 if (x.readyState == 4)
    27 callback(x.responseText);
    28
    29 if(x_call.stop) x_call.stop()
    30 }
    31 x.send(post_data);
    32 delete x;
    33 }
    34
    35
    36 function mymethod()
    37 {
    38 x_call( "kio", {"jo":12,"jim":"hello"},
    39 function(data) {
    40 $("jo").innerHTML=data;
    41 }
    42 )
    43 }
    44
    45 function myinit()
    46 {
    47 x_call.start=function(){$("btn").value="";};
    48 x_call.stop=function(){$("btn").value="ok";};
    49 }
    50
    51 </script>
    52 </head>
    53 <body onload='myinit();'>
    54
    55
    56 <button id="btn" onclick="mymethod()">test</button>
    57 <div id="jo"></div>
    58
    59 </body>
    60 </html>
    Posted by manatlan to html html javascript ... saved by 2 persons ... 0 comments ... 10 months, 1 week
  3. Envoyer un mail html avec python

    Comment envoyer un mail au format html en python. Pratique pour de gros envois de mail.

     1 import smtplib
    2 import MimeWriter
    3 import mimetools
    4 import StringIO
    5
    6 def sendHtmlMail(to,frommail,text,html):
    7 encoding = "base64"
    8 charset = "iso-8859-15"
    9
    10 #déclaration des buffers
    11 out = StringIO.StringIO()
    12 htmlin = StringIO.StringIO(html)
    13 txtin = StringIO.StringIO(html)
    14
    15 #déclaration et initialisation du writer
    16 writer = MimeWriter.MimeWriter(out)
    17 writer.addheader("Subject", text)
    18 writer.addheader("MIME-Version", "1.0")
    19 writer.addheader("From", frommail)
    20 writer.addheader("To", to)
    21 writer.startmultipartbody("alternative")
    22 writer.flushheaders()
    23
    24 #ajout de la partie text
    25 textPart = writer.nextpart()
    26 textPart.addheader("Content-Transfer-Encoding", encoding)
    27 pout = textPart.startbody("text/plain", [("charset", charset)])
    28 mimetools.encode(txtin, pout, encoding)
    29 txtin.close()
    30
    31 #On ajoute la partie html
    32 htmlPart = writer.nextpart()
    33 htmlPart.addheader("Content-Transfer-Encoding", encoding)
    34 pout = htmlPart.startbody("text/html", [("charset", charset)])
    35 mimetools.encode(htmlin, pout, encoding)
    36 htmlin.close()
    37
    38 #on clot le mail
    39 writer.lastpart()
    40 mail = out.getvalue()
    41 out.close()
    42 smtp = smtplib.SMTP("localhost")
    43 #smtp.connect()
    44 smtp.sendmail(frommail, [to], mail)
    45 smtp.close()
    Posted by Fufu to python python mail ... saved by 7 persons ... 0 comments ... 1 year, 2 months
  4. Création d'un mail html en python

    Cette classe permet d'envoyer un mail au format HTML en python. Très pratique pour de l'encoi de mail en masse.

     1 CLASSE MAIL.PY
    2
    3 import smtplib
    4 import MimeWriter
    5 import mimetools
    6 import StringIO
    7
    8 def sendHtmlMail(to,frommail,text,html):
    9 encoding = "base64"
    10 charset = "iso-8859-15"
    11
    12 #déclaration des buffers
    13 out = StringIO.StringIO()
    14 htmlin = StringIO.StringIO(html)
    15 txtin = StringIO.StringIO(html)
    16
    17 #déclaration et initialisation du writer
    18 writer = MimeWriter.MimeWriter(out)
    19 writer.addheader("Subject", text)
    20 writer.addheader("MIME-Version", "1.0")
    21 writer.addheader("From", frommail)
    22 writer.addheader("To", to)
    23 writer.startmultipartbody("alternative")
    24 writer.flushheaders()
    25
    26 #ajout de la partie text
    27 textPart = writer.nextpart()
    28 textPart.addheader("Content-Transfer-Encoding", encoding)
    29 pout = textPart.startbody("text/plain", [("charset", charset)])
    30 mimetools.encode(txtin, pout, encoding)
    31 txtin.close()
    32
    33 #On ajoute la partie html
    34 htmlPart = writer.nextpart()
    35 htmlPart.addheader("Content-Transfer-Encoding", encoding)
    36 pout = htmlPart.startbody("text/html", [("charset", charset)])
    37 mimetools.encode(htmlin, pout, encoding)
    38 htmlin.close()
    39
    40 #on clot le mail
    41 writer.lastpart()
    42 mail = out.getvalue()
    43 out.close()
    44 smtp = smtplib.SMTP("localhost")
    45 #smtp.connect()
    46 smtp.sendmail(frommail, [to], mail)
    47 smtp.close()
    Posted by Fufu to python python mail html ... saved by 2 persons ... 0 comments ... 1 year, 2 months
  5. Bouton simple

    C'est une méthode simple pour transformer les liens en boutons. Cette méthode n'a rien d'original mais elle permet d'obtenir le même affichage sous IE et mozilla. Sans vrai bidouille au niveau du CSS. Attention au texte dans le bouton, il peut dépasser d'un navigateur à l'autre. L'astuce vient de l'encapsulation de la ligne de boutons dans un "div" de hauteur fixe.

     1 Partie HTML :
    2 <div id="Menu1Ligine">
    3 <div class="ElementMenu">
    4 <a href="First.html">One</a>
    5 </div>
    6 <div class="ElementMenu">
    7 <a href="Second.html">Two</a>
    8 </div>
    9 </div>
    10
    11 Partie CSS :
    12 .ElementMenu a {
    13 float : left;
    14 padding : 3px;
    15 min-width: 120px;
    16 width: 120px;
    17 height: 18px;
    18 text-align: center;
    19 text-decoration: none;
    20 border:1px solid #FCC212;
    21 margin : 3px;
    22 color: #000000;
    23 }
    24
    25 .ElementMenu a:hover {
    26 background-color:#EEA60D;
    27 border:1px solid #FCC212;
    28 color: #FFFFFF;
    29 }
    30
    31 .ElementMenu a:active {
    32 background-color:#EEA60D;
    33 border:1px solid #FCC212;
    34 color: #FFFFFF;
    35 }
    36
    37 #Menu1Ligine {
    38 display : block;
    39 margin : 0px;
    40 height : 25px;
    41 padding-top : 95px;
    42 }
    Posted by 33cl to css css html ... saved by 5 persons ... 0 comments ... 1 year, 2 months
  6. Decode Html entities

    exemple d'utilisation : print decode_htmlentities("l'eau")

     1 from htmlentitydefs import name2codepoint as n2cp
    2 import re
    3
    4 def substitute_entity(match):
    5 ent = match.group(2)
    6 if match.group(1) == "#":
    7 return unichr(int(ent))
    8 else:
    9 cp = n2cp.get(ent)
    10
    11 if cp:
    12 return unichr(cp)
    13 else:
    14 return match.group()
    15
    16 def decode_htmlentities(string):
    17 entity_re = re.compile("&(#?)(\d{1,5}|\w{1,8});")
    18 return entity_re.subn(substitute_entity, string)[0]
    Posted by manatlan to python html decode entities ... saved by 1 person ... 0 comments ... 1 year, 2 months
showing 10, 25, 50 items per pages

Pages : 1

Flux RSS friendsnippetLatest snippets


More...