Send to A Friend And Java Problem

Discussion in 'HTML' started by Steve Horrillo, Jun 24, 2005.

  1. I can't figure out why this script won't insert the subject in the email and
    why can't I control the font and size being used? I'm not sure where to post
    this. Let me know where if this is OT.


    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function isPPC() {
    if (navigator.appVersion.indexOf("PPC") != -1) return true;
    else return false;
    }
    if(isPPC()) {
    document.write('<b>Send <A CLASS="contact" HREF=\"mailto:\?subject\=Take a
    look at website I found.?body=You can see this website at
    http://www.BrokerAgentTraining.com\" onMouseOver="window.status=\'Send your
    friends e-mail about this website\'; return true" TITLE="Send your friends
    e-mail about this website">this website<\/A> to a friend</b>');
    }
    else { document.write('<b>Send <A CLASS="contact" HREF=\"mailto:\?body\=Take
    a look at this website I found. You can see this website at
    http://www.BrokerAgentTraining.com\" onMouseOver="window.status=\'Send your
    friends e-mail about this website\'; return true" TITLE="Send your friends
    e-mail about this website">this website<\/A> to a friend</b>');
    }
    // End -->
    </script>


    --
    Warmest regards,

    Steve Horrillo, Realtor / CEO / C.Ht.
    http://brokeragenttraining.com (Advanced training for real estate
    professionals)
    http://over100percent.com (Realtors earn over 100 percent
    http::/hipfsbo.com (a helpful place for the serious home seller or buyer who
    is open to new ideas)
     
    Steve Horrillo, Jun 24, 2005
    #1
    1. Advertising

  2. Steve Horrillo

    microchip Guest

    microchip, Jun 24, 2005
    #2
    1. Advertising

  3. Steve Horrillo wrote:

    > I can't figure out why this script won't insert the subject in the email and
    > why can't I control the font and size being used? I'm not sure where to post
    > this. Let me know where if this is OT.
    >
    >
    > <SCRIPT LANGUAGE="JavaScript">
    > <!-- Begin
    > function isPPC() {
    > if (navigator.appVersion.indexOf("PPC") != -1) return true;
    > else return false;
    > }
    > if(isPPC()) {
    > document.write('<b>Send <A CLASS="contact" HREF=\"mailto:\?subject\=Take a
    > look at website I found.?body=You can see this website at
    > http://www.BrokerAgentTraining.com\" onMouseOver="window.status=\'Send your
    > friends e-mail about this website\'; return true" TITLE="Send your friends
    > e-mail about this website">this website<\/A> to a friend</b>');
    > }
    > else { document.write('<b>Send <A CLASS="contact" HREF=\"mailto:\?body\=Take
    > a look at this website I found. You can see this website at
    > http://www.BrokerAgentTraining.com\" onMouseOver="window.status=\'Send your
    > friends e-mail about this website\'; return true" TITLE="Send your friends
    > e-mail about this website">this website<\/A> to a friend</b>');
    > }
    > // End -->
    > </script>
    >
    >


    Your JavaScript has a problem with quotes my friend. My advice when
    writing complicated strings with quotes is to build up the string in
    bits in a buffer variable. Much much easier to debug.

    var buf='<b>Send <A CLASS="contact" HREF="mailto:?subject=Take a';
    buf+='look at website I found.&body=You can see this website at';
    buf+=' http://www.BrokerAgentTraining.com" onMouseOver="window.status=';
    buf+="'Send your friends e-mail about this website'; return true";
    buf+='" TITLE="Send your friends e-mail about this website">this
    website</a> to a friend</b>';


    document.write(buf);

    Also, mailto link are not reliable, and not all clients will fill in the
    body...

    And the separator from the subject should be a '&' not '?'
    "mailto:?subject=Some subject&body=Your body text"

    Lastly this is a JavaScript, not Java problem.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Jun 24, 2005
    #3
  4. Steve Horrillo

    RobG Guest

    Steve Horrillo wrote:
    > I can't figure out why this script won't insert the subject in the email and
    > why can't I control the font and size being used? I'm not sure where to post


    Which font and size? In the e-mail or on the page? One 'mailto' is
    using body, the other subject. Was that intended? Otherwise, they
    seem to do exactly the same thing.

    If you mean in the e-mail, you only have whatever is supported by the
    e-mail client, and you have no idea what that is, what is supports or
    even if there is one configured. So you are taking pot luck that this
    will work at all.

    I have no idea why you are even testing for 'PPC' in the navigator
    appName string, but here goes...

    > this. Let me know where if this is OT.
    >
    >
    > <SCRIPT LANGUAGE="JavaScript">


    The language attribute is depreciated, type is required:

    <script type="text/javascript">

    > <!-- Begin


    Hiding script element content is unnecessary and potentially harmful -
    don't do it.

    > function isPPC() {
    > if (navigator.appVersion.indexOf("PPC") != -1) return true;


    It is very unreliable to depending on the browser to telling you
    honestly what the platform is. Accept that it will be wrong a good
    percentage of the time (but that is likely not really an issue in this
    case).

    What is the point of detecting 'PPC'?

    > else return false;
    > }


    A simpler (though no more accurate) function is:

    function isPPC() {
    return /PPC/.test(navigator.appVersion);
    }

    > if(isPPC()) {
    > document.write('<b>Send <A CLASS="contact" HREF=\"mailto:\?subject\=Take a
    > look at website I found.?body=You can see this website at
    > http://www.BrokerAgentTraining.com\" onMouseOver="window.status=\'Send your
    > friends e-mail about this website\'; return true" TITLE="Send your friends
    > e-mail about this website">this website<\/A> to a friend</b>');
    > }


    Try setting our your code with clear 'blocking' to make errors easier
    to detect.

    document.write(
    '<b>Send <A CLASS="contact" HREF="mailto:?subject=Take a',
    ' look at website I found.?body=You can see this website at',
    ' http://www.BrokerAgentTraining.com\" ',
    ' onMouseOver="window.status=\'Send your friends e-mail',
    ' about this website\'; return true;"',
    ' TITLE="Send your friends an e-mail about this website">',
    ' this website<\/A> to a friend<\/b>'
    );

    > else { document.write('<b>Send <A CLASS="contact" HREF=\"mailto:\?body\=Take
    > a look at this website I found. You can see this website at
    > http://www.BrokerAgentTraining.com\" onMouseOver="window.status=\'Send your
    > friends e-mail about this website\'; return true" TITLE="Send your friends
    > e-mail about this website">this website<\/A> to a friend</b>');


    document.write(
    '<b>Send <A CLASS="contact" HREF=\"mailto:\?body\=Take a',
    ' look at this website I found. You can see this website at',
    ' http://www.BrokerAgentTraining.com\" ',
    ' onMouseOver="window.status=\'Send your friends e-mail',
    ' about this website\'; return true"',
    ' TITLE="Send your friends e-mail about this website">',
    ' this website<\/A> to a friend<\/b>'
    );

    > }
    > // End -->
    > </script>
    >
    >


    Here's a different approach: put the two options in your page so that
    they both display. Wrap each in a div and give them an ID. Now make
    one disappear (say the one for PPC true) by setting its enclosing div's
    display to 'none'.

    Run your test in a script element just after the links or as a body
    onload event. If PPC is true, change the hidden div's display to ''
    and the other to 'none', e.g. (please excuse wrapping of long attribute
    values, it should still cut 'n paste as source code just fine)


    <div id="forPPC" style="display: none;"><b>Send <A CLASS="contact"
    HREF="mailto:?subject=Take a look at website I found.&body=You can
    see this website at http://www.BrokerAgentTraining.com"
    onMouseOver="
    window.status='Send your friends e-mail about this website';
    return true;"
    TITLE="Send your friends an e-mail about this website"
    > this website</A> to a friend (PPC)</b></div>


    <div id="forOther"><b>Send <A CLASS="contact"
    HREF="mailto:?subject=Take a look at website I found.&body=You can
    see this website at http://www.BrokerAgentTraining.com"
    onMouseOver="
    window.status='Send your friends e-mail about this website';
    return true;"
    TITLE="Send your friends an e-mail about this website"
    > this website</A> to a friend (non-PPC)</b></div>


    <script type="text/javascript">
    if ( /PPC/.test(navigator.appVersion)
    && document.getElementById
    && document.body.style ) {
    document.getElementById('forPPC').style.display = '';
    document.getElementById('forOther').style.display = 'none';
    }
    </script>


    If all goes to plan, 'PPC' users with JavaScript enabled and honest
    browsers will see the first A and maybe when they click on it their
    e-mail client will start with your parameters. In any other case,
    provided the style object & display property are supported, only the
    second A will be shown.



    --
    Rob
     
    RobG, Jun 24, 2005
    #4
  5. Steve Horrillo

    Toby Inkster Guest

    Steve Horrillo wrote:

    > I can't figure out why this script won't insert the subject in the email

    [snip]
    > if(isPPC()) {
    > document.write('<b>Send <A CLASS="contact" HREF=\"mailto:\?subject\=Take a

    [snip]
    > }
    > else { document.write('<b>Send <A CLASS="contact" HREF=\"mailto:\?body\=Take

    [snip]
    > }


    The "else" part of the script doesn't try to set a subject line -- it only
    tries to set a body.

    So unless your browser contains "PPC" in its user-agent string (which I
    think only some old versions of Internet Explorer for Mac do), you will
    get an empty subject line.

    It's a stupid script anyway. You should be doing this server-side.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Jun 24, 2005
    #5
  6. "microchip" <> writes:

    > 1. "<!----- Begin" is an invalid javascript function. It should have
    > the slashes in front of it (like the end).


    He wrote "<!-- Begin". That is at least a valid HTML comment starter.

    There is no reason to have "<!--" in the script element at all, so it
    should not be commented, just removed.

    If it is not removed, it must be assumed that the author intends it to
    work as an HTML comment for browsers not understanding that the script
    element content should not be rendered (which includes pretty much no
    browser newer than Netscape 2). For that purpose, there should not be
    anything outside of the HTML comment, so there should not be slashes
    in front of it.

    > 3.Towards the end you put "<\/a>" instead of </a>


    That is correct. You should always escape the sequence "</" when
    it occurs inside a script element. He should do the same for "</b>".

    /L
    --
    Lasse Reichstein Nielsen -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Jun 24, 2005
    #6
  7. Steve Horrillo wrote:
    > I can't figure out why this script won't insert the subject in the email and
    > why can't I control the font and size being used? I'm not sure where to post
    > this. Let me know where if this is OT.
    >
    >
    > <SCRIPT LANGUAGE="JavaScript">

    <snip>

    What has this to do with Java whatsoever?

    Possibly this?

    http://smjg.port5.com/faqs/web/js/javaisnotjs.html

    Stewart.

    --
    My e-mail is valid but not my primary mailbox. Please keep replies on
    the 'group where everyone may benefit.
     
    Stewart Gordon, Jun 24, 2005
    #7
  8. Steve Horrillo

    VK Guest

    The border line: mailto pseudo-protocol was used 100's and 1000's of
    times to break the domain security over the last 15 years. It has all
    imaginable security limitations. It may be the most up-to-date secure
    protocol in the Interner :)

    You may want to read this ancient (relatively) thread:
    <http://groups-beta.google.com/group/comp.lang.javascript/browse_frm/thread/2602a35ef4a14ac1/4d9084137519a2f2?q=mailto+group:comp.lang.javascript&rnum=3&hl=en#4d9084137519a2f2>
     
    VK, Jun 25, 2005
    #8
  9. VK wrote:

    > The border line: mailto pseudo-protocol was used 100's and 1000's of
    > times to break the domain security over the last 15 years.


    Rubbish. `mailto:' just does not work; it is not a security issue at all.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jul 12, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S2V2aW4gQnVydG9u?=

    Pre-Send Request Headers, Pre-Send Request Content

    =?Utf-8?B?S2V2aW4gQnVydG9u?=, Dec 31, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,127
    =?Utf-8?B?S2V2aW4gQnVydG9u?=
    Dec 31, 2004
  2. Gene Ellis
    Replies:
    3
    Views:
    721
    GIMME
    Jun 24, 2004
  3. kornkreismuster
    Replies:
    5
    Views:
    874
    John Ersatznom
    Jan 8, 2007
  4. pavi
    Replies:
    0
    Views:
    1,388
  5. Peter
    Replies:
    2
    Views:
    310
    Öö Tiib
    Jun 6, 2013
Loading...

Share This Page