refer URL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • moon

    refer URL

    Hello,

    I want to make a "send to friend" page,
    I found a free to use script but it sends the URL that the visitor is on.
    The script opens the default mailprogram and send the mail

    Can I change the script , so I can send another URL instead of the URL the
    visitor is on?
    (I tried everything but nothing works, I'm not good at writing scripts as
    well)

    here is the script, please advice me what I have to change

    thanks


    u = window.location ;
    m = "I thought this might interest you...";
    function mailThisUrl() {
    good = false
    checkEmailAddre ss(document.eMa iler.address);
    if (good) {
    // the following expression must be all on one line...
    window.location =
    "mailto:"+docum ent.eMailer.add ress.value+"?su bject="+m+"&bod y="+document.ti t
    le+" "+u;


  • mscir

    #2
    Re: refer URL

    moon wrote:
    <snip>[color=blue]
    > Can I change the script , so I can send another URL instead of the URL the
    > visitor is on?
    >
    > u = window.location ;
    > m = "I thought this might interest you...";
    > function mailThisUrl() {
    > good = false
    > checkEmailAddre ss(document.eMa iler.address);
    > if (good) {
    > // the following expression must be all on one line...
    > window.location =
    > "mailto:"+docum ent.eMailer.add ress.value+"?su bject="+m+"&bod y="+document.ti t
    > le+" "+u;[/color]

    Maybe something like this. I'm assuming good is set to true in the
    checkEmailAddre ss function if it says the address is valid.

    u = 'http://www.google.com' ; // put the url you want to send here
    m = "I thought this might interest you...";
    function mailThisUrl() {
    good = false;
    checkEmailAddre ss(document.eMa iler.address);
    if (good)
    window.location =
    "mailto:"+docum ent.eMailer.add ress.value+"?su bject="+m+"&amp ;body="+documen t.title+"
    "+u;
    }

    Mike

    Comment

    • moon

      #3
      Re: refer URL


      thanks mike, it works!! :)
      I had tried to put "http://www.google.com" ; instead 'http://www.google.com'
      and it did not work, but yours do.
      Do you have an idea how I can add some more in the message, right now it say
      the title and the URL in the message.
      It's not so important but would be nice if I could add some more in message

      thanks again
      Gert
      [color=blue]
      >
      > Maybe something like this. I'm assuming good is set to true in the
      > checkEmailAddre ss function if it says the address is valid.
      >
      > u = 'http://www.google.com' ; // put the url you want to send here
      > m = "I thought this might interest you...";
      > function mailThisUrl() {
      > good = false;
      > checkEmailAddre ss(document.eMa iler.address);
      > if (good)
      > window.location =
      >[/color]
      "mailto:"+docum ent.eMailer.add ress.value+"?su bject="+m+"&amp ;body="+documen t
      ..title+"[color=blue]
      > "+u;
      > }
      >
      > Mike
      >[/color]


      Comment

      • mscir

        #4
        Re: refer URL

        moon wrote:

        I missed a few things in my first reply, I'll try to correct them in
        this message:

        First of all, using 'mailto:' is not recommended:





        If you still want to use mailto...
        [color=blue]
        > u = window.location ;
        > m = "I thought this might interest you...";[/color]

        These variables should be local - if they are only used in the function
        mailThisUrl - they should be declared using var in the function. Use
        local variables whenever possible. Here's a little reading about
        declaring variables, and global/local variable scope.




        [color=blue]
        >[/color]
        "mailto:"+docum ent.eMailer.add ress.value+"?su bject="+m+"&bod y="+document.ti t[color=blue]
        > le+" "+u;[/color]

        I broke the string into pieces and placed it in a local variable so it
        is easier to see what's going on. Change the last line to include the
        additional message body text you want instead of "test string'.

        var msgstring = 'mailto:' + document.eMaile r.address.value ;
        msgstring += '?subject=' + subject;
        msgstring += '&body=' + document.title + ' ' + sendurl + ' ';
        msgstring += 'test string' //place message text within single quotes


        Give this version a try and see if it does what you want, if you don't
        use CGI or the free alternatives listed above:

        function mailThisUrl() {
        var sendurl = 'http://www.google.com' ;
        var subject = "I thought this might interest you...";
        var good = false;
        checkEmailAddre ss(document.eMa iler.address.va lue);
        if (good) {
        var msgstring = 'mailto:' + document.eMaile r.address.value ;
        msgstring += '?subject=' + subject;
        msgstring += '&body=' + document.title + ' ' + sendurl + ' ';
        msgstring += 'test string' //place message text within single quotes
        window.location = msgstring;
        }
        }

        Please don't top post, it messes up the Q&A flow.
        MIke

        Comment

        Working...