【发布时间】:2019-08-24 12:46:32
【问题描述】:
我有一个 Google AppScript,它生成用于格式化电子邮件的 HTML 代码。我会输出一个具有相同宽度的列的表格,在 PC 和手机上,表格以不同的方式显示。
其他代码 ..
body += "<table border=2><tbody><tr>";
//Inserisco l'header del messaggio
if (report_headline[0].length > 0) body += CreateHTMLTableRow(report_headline, is_header = true);
//costruisco la tabella con i dati del report dei messaggi
if (report_attachement[0].length > 0) body += CreateHTMLTableRow(report_attachement, is_header = false);
//costruisco la tabella con i dati del report dei pagamenti
if (report_payments[0].length > 0) body += CreateHTMLTableRow(report_payments, is_header = false);
// Close the table tag
body += "</tbody></table>";
.. 其他代码
//Create an HTML table row from an array
function CreateHTMLTableRow(array,is_header){
var htmlBody = '';
var n_row = array.length;
var n_col = 0;
var tr_width = 0;
for (var r = 0; r < n_row; r++) {
n_col = array[r].length;
tr_width = Math.round(100/n_col);
for (var c = 0; c < n_col; c++) {
//First row has header <th> tag
if(is_header){
if(array[r][c] != ""){
htmlBody += '<th bgcolor="lightgrey" width="'+tr_width+'"%>'+array[r][c]+"</th>";
}
else htmlBody += "<th>"+"</th>";
}
//Other rows have the normal <td>
else {
if(array[r][c] != ""){
htmlBody += '<td width="'+tr_width+'"%>'+array[r][c]+"</td>";
}
else htmlBody += "<td>"+"</td>";
}
}
htmlBody += "</tr>";
}
return htmlBody;
}
移动设备上的 gmail 客户端以正确的方式显示表格,而在我的笔记本电脑上,第二行都在同一行。
【问题讨论】:
-
能否在您的笔记本电脑浏览器开发工具中显示生成的 html 源代码?
-
试试
htmlBody += "</tr><tr>"
标签: html email google-apps-script mobile gmail