SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question mailtto: using javascript from image link

    How do I create an email link using javascript attached to an image link?

    The simpler methods I have so far been able to find only work within form elements.

    I have also tried...

    window.location="mailto:contact@mydomain.com"

    parent.location="mailto:contact@mydomain.com"

    location.href="mailto:contact@mydomain.com"


    ... none of which seem to work.

    What's the secret? Where am I going wrong?
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <img title="blah" width="100" height="100" src="mypic.jpg" onclick="window.parent.location ='mailto:contact@mydomain.com'" /><br />

    <img title="blah" width="100" height="100" src="mypic.jpg" onclick="window.location.href ='mailto:contact@mydomain.com'" /><br />

    there u go

  3. #3
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Darn, I never thought to throw everything in

    Thx (yet again) Andrew.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or call it from a function sure you can figure it out

  5. #5
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Already had that bit nailed down.

    Bolted onto the back end of a conditional confirm()

    function goEmail() {
    if (confirm('This link will launch your \nemail application.\n\nContinue?'))
    window&#46;location&#46;href='mailto&#58;contact@mydomain.com';
    }


    Not the most graceful of methods, but less aggravating than an unexpected email client launch.
    (The link is being used on my contact page which already has a form. I just included the 'simple' email link to cover both options.)

    I'm getting there- slowly
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature


Bookmarks

Posting Permissions

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