javascript - How to pass variables to mailto method - Stack Overflow

I need to know if its possible to pass variables to the mailto: method.I want to have something along t

I need to know if its possible to pass variables to the mailto: method.

I want to have something along the lines like this, so it opens a new email on outlook.

var email = "[email protected]"
var subject = "test"
window.href = "mailto:email?subject=subject"

Now i want to know if i can pass these variables. I don't care about the body of the email I just wanna have the email address and the subject line passed in. I can't ActiveXObject because my code is on the server side rather then the client side so it wont have permission to create objects. Or at least thats what i got from reading into opening outlook from javascripts.

I need to know if its possible to pass variables to the mailto: method.

I want to have something along the lines like this, so it opens a new email on outlook.

var email = "[email protected]"
var subject = "test"
window.href = "mailto:email?subject=subject"

Now i want to know if i can pass these variables. I don't care about the body of the email I just wanna have the email address and the subject line passed in. I can't ActiveXObject because my code is on the server side rather then the client side so it wont have permission to create objects. Or at least thats what i got from reading into opening outlook from javascripts.

Share Improve this question asked Sep 15, 2013 at 1:34 ZeRaTuL_jFZeRaTuL_jF 5922 gold badges4 silver badges20 bronze badges 7
  • 1 You replied to your own question. Just use window.location.href = "mailto:" + email + "?subject=" + subject;? – opatut Commented Sep 15, 2013 at 1:37
  • @opatut the problem is that i have tried the expression that you have, and all it does is print the actual +email+ into the email rather than what the variable contains. Do i need something special or am i missing something. – ZeRaTuL_jF Commented Sep 15, 2013 at 1:58
  • You are probably mixing or missing quotation marks. They are important! – opatut Commented Sep 15, 2013 at 2:02
  • @ZeRaTuL_jF: this works fine - jsfiddle/CUEEr – Qantas 94 Heavy Commented Sep 15, 2013 at 2:03
  • I guess I'm just missing typing something. I shall let you guys know when I get back to working on this. Thank you – ZeRaTuL_jF Commented Sep 15, 2013 at 2:22
 |  Show 2 more ments

1 Answer 1

Reset to default 2

You are missing some quotes somewhere. Make sure your quoting looks similar to this:

window.location.href = "mailto:" + email + "?subject=" + subject;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745138850a4613333.html

相关推荐

  • javascript - How to pass variables to mailto method - Stack Overflow

    I need to know if its possible to pass variables to the mailto: method.I want to have something along t

    7小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信