Forum Moderators: open

Message Too Old, No Replies

Workaround href character limit

         

aspdaddy

8:08 pm on Aug 12, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have an app that makes useful href mailto links for users to send each other by opening text files on the server and inserting messages into the to, subject and body (quite long message) of client side email programs.

A few of these are now hitting the 2000 and something character limit which stops the link opening the email program on some browsers.

Although the text files are created by users and opened on the server, the links are all standard client side href mailto links done in HTML.

Does any creative person here know how to to get around this HTML character limit by writing the link with JavaScript or some other method of encoding text content to be smaller.

Thanks.

penders

8:47 pm on Aug 12, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just wondering about the relationship between your server-side text files and your mailto links...? Are the contents of these text files 'embedded' in the mailto link? If so, why don't you use a server-side script to do the mailing?

If you are relying on the clients email program to do the mailing (from the mailto link) then however you manage to compress this link, the email program is going to have to uncompress it - and I think that is going to be the problem. (?)

Demaestro

9:26 pm on Aug 12, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I was also thinking that if you compress it somehow then you will still need to decompress it for the mail client

My only thought was trying to populate the href property with JS, but if the issue is with the mail client then this may not help at all, worth trying tho.


<a href="" id="mail_link" onclick="return doHref();">My Link</a>

<script>
function doHref() {
var the_href = 'areallylongstring';
var the_link = document.getElementById('mail_link');
the_link.href = the_href;
return true;
}
</script>

penders

10:48 pm on Aug 12, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



@Demaestro Nice idea, although isn't this going to reach the "2000 and something character limit" as before since you are assigning back to the href attribute?

Just a thought, could you assign your result to
location.href='mailto:...'
, or does this also hit this 2000+ char limit?

astupidname

9:04 am on Aug 14, 2011 (gmt 0)

10+ Year Member



The problem here is that it's actually http GET request urls that have the limitation you are running in to of about 2000 characters. It does not matter if you use a links href with mailto: or use location.href='mailto: or open a new window with mailto: or use a form's action attribute with a mailto: in it, they're all GET url requests.
There's no way around it. Compression would not make any sense either, as the email client would have no clue what to do about it or that anything need be doing actually. One possible alternative comes to mind which would involve the user a slight bit more and may need to instruct them a small bit. Rather than sending the body of the message through the mailto: you could give the users a button to click with which they would automatically copy the body of the message onto their clipboard, then at the same time do location.href='mailto:thename@theemailaddress?subject=bogusness'; and then when their email program opens they can just right click and paste the message in to the body. But note there are no good javascript-only solutions for copying to clipboard which work well cross-browser, the only truly good solution is a combo of javascript and flash which is known as ZeroClipboard: see ZeroClipboard [code.google.com]
I myself use ZeroClipboard, so if you're at all interested in going that route and need help as to how to implement, or would like an example, just ask.