I am trying to call a mailto:
URI which is stored in a variable. When I do window.location.href = mailto_link;
Firefox gives me the following error:
NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057
(NS_ERROR_ILLEGAL_VALUE) [nsIDOMLocation.href]
window.location.href = mailto_link;`
What IE says:
Object doesn't support this property or method
The code works in Chrome but not in IE nor Firefox.
my original function:
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;
}
UPDATE 1
I found out what was causing the issue for IE, although I am still looking to resolve it for Firefox. The problem for IE was that I had a console.log();
which wouldn't be recognized (IE8 and lower versions).
Here is a console.log()
of the content of 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