Creating a variable hyperlink using javascript in html

Anonymous
timer Asked: Jun 20th, 2013
account_balance_wallet $5

Question Description

I want to create a variable in html, and it's value is a link to a website. This is for a weekly email template and the link changes every week and the same link occurs several times in the template. So instead of going through and copy pasting a new link several times in the code, I want to just change the value of the variable so it just updates all the links in one go.

I'm a complete rookie at coding and any help is appreciated

Tutor Answer

Wesley Painter
School: UC Berkeley

Hey, IJames,

I wish I could tell you this is easily done, but it isn't. HTML email is a whole different beast from an HTML website, as I had the pleasure of learning earlier this year.  Please read up on this link before you actually write an HTML email.

http://24ways.org/2009/rock-solid-html-emails/

This next link shows compatibility lists of email clients and what version of CSS they can handle.

http://www.campaignmonitor.com/css/

This last link is so you can test your email before you send it out to see if there are any errors, or to get it to clean up your html and optimize it for email.

http://premailer.dialect.ca/


Now that you see html email is much more of a hassle, you may realize that it won't be possible to use code that executes client side - it's just not safe and no one really allows it in email.  If you are using php, then this is your easy solution. Decide on a good variable name, and define it.  Then place that variable each time you want the link.  PHP will work because it is executed server-side, so you won't have to worry about any PHP code reaching the client.  Here is a super easy example that will output "Here is a link to likeplum: http://www.likeplum.com."

<?php
$link = "http://www.likeplum.com"; echo "Here is a link to likeplum: $link"; ?>

flag Report DMCA
Review

Anonymous
Tutor went the extra mile to help me with this essay. Citations were a bit shaky but I appreciated how well he handled APA styles and how ok he was to change them even though I didnt specify. Got a B+ which is believable and acceptable.

Similar Questions
Hot Questions
Related Tags
Study Guides

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors