Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Aug 2003
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Success! creating href link from string variable

    I've tried every possible combination except the right one obviously. I'm trying to create an href link out of a variable that contains a string address and use it in an email link with subject and body, etc. Please tell me what I'm doing wrong...
    Something with the link method I think....

    Assume the variable finalString already contains an http address.
    ...
    var=finalString;

    document.write('<b><A CLASS="contact" HREF=\"mailto:\?subject\=Take a look at this page I found, ' + document.title + '?body=You can see this page at: ' + (link(finalString)) + '\" onMouseOver="window.status=\'Send this page to a friend!\'; return true" TITLE="Send this page to a friend!">Send this page to a friend!<\/A></b>');
    Last edited by pa2stepper; 10-24-2003 at 07:11 PM.

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    well there are a couple problems
    first, what are all the \ s for those are unecisary
    second, what is link() i doest appear to be any system function IE6
    third, were you use ' for quoting something already inside single quotes (were u do the window.status)
    also: its </a> not <\/a> and why isnt there a address to mailto and the TITLE propertie is unecisary

    after fixing that you can get this


    document.write('<b><a CLASS="contact" HREF="mailto:somebody@something.com?subject=Take a look at this page I found, ' + document.title + '?body=You can see this page at: ' + finalString + '" >Send this page to a friend!</a></b>');

    if you wanted the status bar change, you would need to make a function that does that, that does not take any arguments
    Last edited by kwhubby; 10-22-2003 at 05:05 AM.
    Kris Hubby
    kwhubby site

  • #3
    New Coder
    Join Date
    Aug 2003
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    almost there - looks like a syntax error ?

    When the email window opened, the body was empty (i was hoping to put the href link in there) and the subject was this:

    Take a look at this page I found, Property Listings -?body=You can see this page at: undefined

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    o i know why were i have ?body= it should be &body=
    Kris Hubby
    kwhubby site

  • #5
    New Coder
    Join Date
    Aug 2003
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    minor glitch - probably easy syntax thing

    please tell me how i can append the string: "&xm=on&ppinc=detail"
    to the variable named finalString below, within the syntax below. finalString contains part of an http address but isn't complete without the rest of the string on the end. I can't seem to get the quotes right! (i know, duh...)
    thank you very much,
    mary



    document.write('<b><a CLASS="contact" HREF="mailto:?subject=Take a look at this property I found! '
    + '&body=You can see this property at: ' + finalString + ' " >Send this page to a friend!</a></b>');
    Last edited by pa2stepper; 10-23-2003 at 04:07 AM.

  • #6
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    im not quite sure what u mean, but do u want to add the string "&xm=on&ppinc=detail" to finalstring?... ud just do finalString = finalString + "&xm=on&ppinc=detail"
    Kris Hubby
    kwhubby site

  • #7
    New Coder
    Join Date
    Aug 2003
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    youre very patient, thank you for returning.
    that's pretty much it - i want to append that weird string but in the document.write statement. believe it or not, the finalString actually contains that weird string but for some reason it's not appearing in the href link inside the email. i tested it by printing it on the page just before the Send This Page To a Friend link and then again right after, and the finalString prints exactly as I need it. Yet when I click on the Send This Page link and Outlook opens, the body contains the href link MINUS that weird portion! I can't figure it out. Here's the link - you can see for yourself.

    http://www.microtechweb.biz/VirtualAssistant/agora.cgi

    click on one of the home categories, and look at a Details page and you'll see the Send This Link to a Friend.

    M

  • #8
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is really nothing more than a guess, but you should be able to use the Unicode character code.

    finalString += '\u0026xm=on\u0026ppinc=detail';

    Give that a shot and see what happens.

  • #9
    New Coder
    Join Date
    Aug 2003
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    I tried to append it after the finalString but it won't add it to the link in the final output. This is baffling! What's really strange though, is that the variable finalString contains exactly the href that i need (through my parsing it) and i tested this - but when it prints inside the email body, it's missing the weird portion.

    so for anybody that wants a brain teaser - here it is: how to append the string "&xm=on&ppinc=detail" onto the variable finalString and make it part of the finalString href.

    document.write('<b><a CLASS= "contact" HREF="mailto:?subject=Take a look at this property I found! ' + '&body=You can see this property at: ' + finalString +'&xm=on&ppinc=detail' +' " >Send this page to a friend!</a></b>');}

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    whenever you're putting querystrings in the url and you expect special characters in it, you should always encode it.

    var subject = escape("Take a look at this property I found!");
    var body = escape("You can see this property at: " + finalString + "&xm=on&ppinc=detail");
    document.write('<b><a CLASS= "contact" HREF="mailto:?subject=' +subject + '&body=' + body + '">Send this page to a friend!</a></b>');

  • #11
    New Coder
    Join Date
    Aug 2003
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile it worked!

    glenn - your solution worked!
    wow - this has been a great lesson for me...
    thanks a lot and thanks to everyone else who responded too...
    maybe someday i can post a reply to one of these questions!
    best,
    mary
    Last edited by pa2stepper; 10-24-2003 at 07:10 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •