我正在尝试调用mailto:
存储在变量中的 URI。当我做window.location.href = mailto_link;
Firefox 给我以下错误:
NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057
(NS_ERROR_ILLEGAL_VALUE) [nsIDOMLocation.href]
window.location.href = mailto_link;`
什么 IE 说:
Object doesn't support this property or method
该代码适用于 Chrome,但不适用于 IE 或 Firefox。
我原来的功能:
function email()
{
var nom = $('#nom').val();nom = encodeURIComponent(nom);
var compagnie = $('#compagnie').val();compagnie = encodeURIComponent(compagnie);
var rue = $('#rue').val();rue = encodeURIComponent(rue);
var ville = $('#ville').val();ville = encodeURIComponent(ville);
var province = $('#province').val();province = encodeURIComponent(province);
var cp = $('#cp').val();cp = encodeURIComponent(cp);
var remarques = $('#remarques').val();if(remarques ==""){remarques = "Aucune remarque.";}remarques = encodeURIComponent(remarques);
var quantite = $('#quantite').val();
var email= "someEmail@somedomain.com";
var subject= "Nouvelle commande";
var body_message= "%0D%0D%0D%0D"+nom+"%0D"+compagnie+"%0D"+rue+"%0D"+ville+", "+province+"%0D"+cp+"%0D%0D%0DRemarques:"+remarques+"%0D%0D Quantit%E9:"+quantite;
var mailto_link = 'mailto:'+email+'?subject='+subject+'&body='+body_message;
window.location.href = mailto_link;
}
更新 1
我发现了导致 IE 问题的原因,尽管我仍然希望为 Firefox 解决它。IE 的问题是我有一个console.log();
无法识别的(IE8 和更低版本)。
这是console.log()
mailto_link的内容:
mailto:someEmail@someDomain.com?subject=Nouvelle commande&body=Charger %0Dmodems des %CEseulement%0D%0D%0D%0Djshad%0Daskjda%0Daskdj%0Daskdj, askdj%0DJ9P%204A1%0D%0D%0DRemarques:asldk%0D%0D Quantit%E9:14