#1 Le 17/07/2012, à 21:58
- Totem
[RESOLU] Utiliser contenu d'une variable Python avec javascript
Bonjour,
j'ai un programme en Python qui se connecte à un serveur de messagerie, qui récupère l'expediteur, le sujet et la date du mail j'aimerai resuperer ces informations et les ajouter dans mon code HTML et afficher le html dans un webview.
voici un exemple de mon code HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Exemple</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery-1.7.2.js"></script>
<link rel="stylesheet" type="text/css" href="style2.css" />
</head>
<body>
<div id="mail_content">
<div id="header_mail">
<table>
<tr>
<td id="label">From:</td>
<td><span id="from"></span></td>
</tr>
<tr>
<td id="label">To:</td>
<td><span id="to"></span></td>
</tr>
<tr>
<td id="label">Subject:</td>
<td><span id="subject"></span></td>
</tr>
<tr>
<td id="label">Date:</td>
<td><span id="date"></span></td>
</tr>
</table>
</div>
<script>
$(function() {
var div = $('#header_mail');
$.data(div, {from: 'abc@gmail.com', to: 'toto@orange.fr', subject: 'Text HTML Yess', date: '17/07/2012'});
var val1 = $.data(div).from;
var val2 = $.data(div).to;
var val3 = $.data(div).subject;
var val4 = $.data(div).date;
$('#from').text(val1);
$('#to').text(val2);
$('#subject').text(val3);
$('#date').text(val4);
});
</script>
</div>
</body>
</html>
Merci d'avance
Dernière modification par Totem (Le 26/07/2012, à 18:40)
il n'existe que deux choses d'infinies, l'univers et la connerie humaine, mais pour l'univers je n'ai pas de certitude absolue
A. Einstein.
Hors ligne
#2 Le 25/07/2012, à 11:52
- AnsuzPeorth
Re : [RESOLU] Utiliser contenu d'une variable Python avec javascript
Bjr,
Tu peux peut être utiliser la commande execute_script de webkit ? Ca appelle une fonction JS dans ton html avec argument si besoin, ca devrait faire ce que tu veux !
Interface graphique pour bash, python ou autre: glade2script
Support Tchat: http://chat.jabberfr.org/muckl_int/inde … ade2script (Hors ligne)
Hors ligne