Mailto question

Discussion in 'Javascript' started by Joh, Dec 16, 2006.

  1. Joh

    Joh Guest

    I'm using mailto to open up an email that have a hyperlink in the body.
    The hyperlink passes two variables Name and Emailadress. The problem is
    that only the first variable Name show up in the hyperlink. It seems
    that javascript takes the & as the end of the body where I use it to
    separate my variables. Anyone know how to deal with this?

    "<script
    language='javascript'>window.open('mailto:&body=http://www.abc.com/test.aspx?Name=abc&EmailAdress=',
    '_blank');</script>"
    Joh, Dec 16, 2006
    #1
    1. Advertising

  2. Joh

    pcx99 Guest

    Joh wrote:
    > I'm using mailto to open up an email that have a hyperlink in the body.
    > The hyperlink passes two variables Name and Emailadress. The problem is
    > that only the first variable Name show up in the hyperlink. It seems
    > that javascript takes the & as the end of the body where I use it to
    > separate my variables. Anyone know how to deal with this?
    >
    > "<script
    > language='javascript'>window.open('mailto:&body=http://www.abc.com/test.aspx?Name=abc&EmailAdress=',
    > '_blank');</script>"
    >


    mailto://?body=http://www.abc.com/test.aspx&Name=abc&subject=a
    subject!

    You didn't ask for it, but I added in a subject too, you can delete it
    (&subject...) if you decide not to use it.

    Hope that helps you out a bit.

    --
    http://www.hunlock.com -- Musings in Javascript, CSS.
    $FA
    pcx99, Dec 16, 2006
    #2
    1. Advertising

  3. Joh

    Joh Guest

    pcx99 skrev:

    > Joh wrote:
    > > I'm using mailto to open up an email that have a hyperlink in the body.
    > > The hyperlink passes two variables Name and Emailadress. The problem is
    > > that only the first variable Name show up in the hyperlink. It seems
    > > that javascript takes the & as the end of the body where I use it to
    > > separate my variables. Anyone know how to deal with this?
    > >
    > > "<script
    > > language='javascript'>window.open('mailto:&body=http://www.abc.com/test.aspx?Var1=abc&Var2=123,
    > > '_blank');</script>"
    > >

    >
    > mailto://?body=http://www.abc.com/test.aspx&Name=abc&subject=a
    > subject!
    >
    > You didn't ask for it, but I added in a subject too, you can delete it
    > (&subject...) if you decide not to use it.
    >
    > Hope that helps you out a bit.
    >
    > --
    > http://www.hunlock.com -- Musings in Javascript, CSS.
    > $FA

    Thanks pcx99 for your response but it doesn't answer my question. My
    problem is that when I try to pass on two variables Var1 and Var2 with
    a hyperlink inside an email that I open with mailto only the first
    variable Var1 show up in the hyperlink. It seams that javascript takes
    & as the end of the email body where I want to use it to separate my
    two varables that are passed on with the hyperlink.
    Joh, Dec 16, 2006
    #3
  4. Joh

    Joh Guest

    Joh skrev:

    > pcx99 skrev:
    >
    > > Joh wrote:
    > > > I'm using mailto to open up an email that have a hyperlink in the body.
    > > > The hyperlink passes two variables Name and Emailadress. The problem is
    > > > that only the first variable Name show up in the hyperlink. It seems
    > > > that javascript takes the & as the end of the body where I use it to
    > > > separate my variables. Anyone know how to deal with this?
    > > >
    > > > "<script
    > > > language='javascript'>window.open('mailto:&body=http://www.abc.com/test.aspx?Var1=abc&Var2=123,
    > > > '_blank');</script>"
    > > >

    > >
    > > mailto://?body=http://www.abc.com/test.aspx&Name=abc&subject=a
    > > subject!
    > >
    > > You didn't ask for it, but I added in a subject too, you can delete it
    > > (&subject...) if you decide not to use it.
    > >
    > > Hope that helps you out a bit.
    > >
    > > --
    > > http://www.hunlock.com -- Musings in Javascript, CSS.
    > > $FA

    > Thanks pcx99 for your response but it doesn't answer my question. My
    > problem is that when I try to pass on two variables Var1 and Var2 with
    > a hyperlink inside an email that I open with mailto only the first
    > variable Var1 show up in the hyperlink. It seams that javascript takes
    > & as the end of the email body where I want to use it to separate my
    > two varables that are passed on with the hyperlink.



    Thanks pcx99 for your response but it doesn't answer my question. My
    problem is that when I try to pass on two variables Var1 and Var2 with
    a hyperlink inside an email that I open with mailto only the first
    variable Var1 show up in the hyperlink. It seams that javascript takes
    & as the end of the email body where I want to use it to separate my
    two varables that are passed on with the hyperlink.

    "<script
    language='javascript'>window.open('mailto:&body=http://www.abc.com/test.aspx?Var1=abc&Var2=123,
    '_blank');</script>"
    Joh, Dec 16, 2006
    #4
  5. Joh

    pcx99 Guest

    Joh wrote:
    > Thanks pcx99 for your response but it doesn't answer my question. My
    > problem is that when I try to pass on two variables Var1 and Var2 with
    > a hyperlink inside an email that I open with mailto only the first
    > variable Var1 show up in the hyperlink. It seams that javascript takes
    > & as the end of the email body where I want to use it to separate my
    > two varables that are passed on with the hyperlink.



    Ah, that's because the & in the url is getting mixed up with the mailto
    address. Basically mailto is using & to separate data and the url you
    have for the body is also using & to separate its data. So the solution
    is to escape the data like this...

    <script language='javascript'>

    window.open('mailto:abc.com?body='+escape('http://www.abc.com/test.aspx?Var1=abc&Var2=123'),
    '_blank');

    </script>

    The escape command basically will change all the spaces, ampersighns,
    question marks and other special symbols into "safe" codes.

    Hope that works a little better for you.


    --
    http://www.hunlock.com -- Musings in Javascript, CSS.
    $FA
    pcx99, Dec 16, 2006
    #5
  6. Joh

    Randy Webb Guest

    Joh said the following on 12/16/2006 7:26 AM:
    > Joh skrev:
    >
    >> pcx99 skrev:
    >>
    >>> Joh wrote:
    >>>> I'm using mailto to open up an email that have a hyperlink in the body.
    >>>> The hyperlink passes two variables Name and Emailadress. The problem is
    >>>> that only the first variable Name show up in the hyperlink. It seems
    >>>> that javascript takes the & as the end of the body where I use it to
    >>>> separate my variables. Anyone know how to deal with this?
    >>>>
    >>>> "<script
    >>>> language='javascript'>window.open('mailto:&body=http://www.abc.com/test.aspx?Var1=abc&Var2=123,
    >>>> '_blank');</script>"
    >>>>
    >>> mailto://?body=http://www.abc.com/test.aspx&Name=abc&subject=a
    >>> subject!
    >>>
    >>> You didn't ask for it, but I added in a subject too, you can delete it
    >>> (&subject...) if you decide not to use it.
    >>>
    >>> Hope that helps you out a bit.
    >>>
    >>> --
    >>> http://www.hunlock.com -- Musings in Javascript, CSS.
    >>> $FA

    >> Thanks pcx99 for your response but it doesn't answer my question. My
    >> problem is that when I try to pass on two variables Var1 and Var2 with
    >> a hyperlink inside an email that I open with mailto only the first
    >> variable Var1 show up in the hyperlink. It seams that javascript takes
    >> & as the end of the email body where I want to use it to separate my
    >> two varables that are passed on with the hyperlink.

    >
    >
    > Thanks pcx99 for your response but it doesn't answer my question. My
    > problem is that when I try to pass on two variables Var1 and Var2 with
    > a hyperlink inside an email that I open with mailto only the first
    > variable Var1 show up in the hyperlink. It seams that javascript takes
    > & as the end of the email body where I want to use it to separate my
    > two varables that are passed on with the hyperlink.
    >
    > "<script
    > language='javascript'>window.open('mailto:&body=http://www.abc.com/test.aspx?Var1=abc&Var2=123,
    > '_blank');</script>"


    Instead of &, try &amp;

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Dec 16, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mailto: question

    , Dec 1, 2007, in forum: ASP General
    Replies:
    3
    Views:
    119
    Adrienne Boswell
    Dec 2, 2007
  2. Mike

    mailto - question

    Mike, Dec 28, 2007, in forum: ASP General
    Replies:
    11
    Views:
    208
    Evertjan.
    Jan 6, 2008
  3. ElvisIsDead

    Mailto: question

    ElvisIsDead, Feb 19, 2004, in forum: Javascript
    Replies:
    12
    Views:
    120
    Brian Genisio
    Feb 20, 2004
  4. Stuart

    Mailto Question

    Stuart, Apr 25, 2007, in forum: Javascript
    Replies:
    1
    Views:
    69
    Elegie
    Apr 25, 2007
  5. Thomas Gagne
    Replies:
    2
    Views:
    306
    Robert Klemme
    Mar 15, 2013
Loading...

Share This Page