How do I use jQuery to convert a url in these three formats?

The url I need to process is:

and it should become:




I don't know how to formulate this one at all, but here are the details:
mailto: email address has to be empty as it will need to be filled in
subject: whatever I can get from: var thisTitle (whose spaces will need to be converted into %20)
body: whatever I can get from: var thisLink (this will be a url link which will need to be converted to the format compatible with the maito syntax.

So in the third case basically the result should look something like: mailto:?subject=Congrats%20Obama&

Please help, as I am completely clueless. The rest of the code for the structure where these links have to go I have already managed but I haven't a clue as to how to generate these links

thanks in advance
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
something like this:

$(function() {
    var url = location.href;
    var title = document.title;
    var facebook = "" + url + "t=" + title;
    var twitter = ""+url+"&via=Mission_Family&original_referer="+url;
    var email = "mailto:?subject=Congrats%20Obama&body="+url+"&t="+title;

Open in new window

badwolfffAuthor Commented:
Hi Rob,

hmmm... I think you misunderstood me. That I knew how to do. What I need is how to convert the normal URL format in to the appropriate format that facebook/twitter/email take (where spaces become %20, : become %3A, etc.)

RobOwner (Aidellio)Commented:
ah sorry, then you just use the encodeURI() function:

$(function() {
    var url = encodeURI(location.href);
    var title = encodeURI(document.title);
    var facebook = "" + url + "t=" + title;
    var twitter = ""+url+"&via=Mission_Family&original_referer="+url;
    var email = "mailto:?subject=Congrats%20Obama&body="+url+"&t="+title;
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

badwolfffAuthor Commented:
Hi Rob,

I am getting the output like this (for another URL):

url =
title = Test%20event-%20by%20partner

I think this needs some other type of encoding, don't you? The http:// should become:     http%3A%2F%2F
badwolfffAuthor Commented:
I managed it with encodeURIComponent :D

thanks for pointing me in the right direction.
RobOwner (Aidellio)Commented:
Yes.  encodeURIComponent()

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
badwolfffAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 500 points for Rob's comment #a40899696
Assisted answer: 0 points for badwolfff's comment #a40899713

for the following reason:

The solution offered was nearly perfect, just needed a bit of tweaking.
RobOwner (Aidellio)Commented:
LOL you beat me by 30 sec :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.