javascript question

  • Started
  • Last post
  • 5 Responses
  • hitsuji

    Just a quick question. I've got one of those forward to a friend forms set up and im just wondering how to make the link of the page be named rather than have the full address.
    so its "Amazon" rather than "http://www.amazon.com".

    here's the code for the message bit of the form. basically i just need to be able to name the window.location bit.
    var initialmsg="Dear friend, check this out "+window.location

  • bigtrickagain0

    maybe you want document.title instead of window.location?

    • that works for putting the title of the page but its not hyperlinkedhitsuji
  • bigtrickagain0

    or initialmsg = "Dear friend, check this out: <a href='" + window.location + "'>" + document.title + "</a>";

    • and that one shows the a tags in the email lol. cheers though, appreciate the helphitsuji
  • hitsuji0

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin

    var initialsubj="Amazon"
    var initialmsg="Dear friend, check this out "+window.location
    var good;
    function checkEmailAddress(field) {

    var goodEmail =
    if (goodEmail) {
    good = true;
    }
    else {
    alert('Please enter a valid address.');
    field.focus();
    field.select();
    good = false;
    }
    }
    u = window.location;
    function mailThisUrl() {
    good = false
    checkEmailAddress(document.eMailer.email);
    if (good) {

    //window.location = "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+document.title+" "+u;
    window.location = "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+initialmsg
    }
    }
    // End -->
    </script>

  • bigtrickagain0

    Hmmm, there's little you can do here i'm afraid. if you use a javascript to initiate an email using the email client of the browser (i.e. using a mailto tag), you are dependent on whether or not that email client supports HTML email, and if so, if they have HTML turned on by default (I'm not even sure, given these conditions, that it will translate your message body as html - it may not). So, the best you can do is just use the document.location, since you can't count on the html tags i pasted to render as HTML.

    • yeah im not whizz with the old java. i keep thinking ive solved it. might find an alternative way. cheers anywayhitsuji
  • acescence0

    the only way you'll get it consistent is by sending the mail from your server via php or something. it's client dependent, i think outlook may be the only one i'm aware of where this is even possible, and it depends on their settings