I didn't seem to find this anywhere, but I'm looking for a text limit code that will add "..." when text is too long.
Also, I'd like to apply to this to any HTTP link wherever it is on the page if that's possible. But I'll be happy with a simple limitor.
You'd want to use the function:string.substr(a, b);If you set a to 0, and b to the length that you want it to be, then the string will be truncated to that length.
This could be used much like:
<script type = 'text/javascript'>
var length = 30;
function cut(x, y) {
return(x.substr(0, y) + "...");
}
for(i = 0, a = get('a', 'tag'); i < a.length; i++)
if(a[i].innerHTML.length > length)
a[i].innerHTML = cut(a[i].innerHTML, length);
</script>
The cut function will truncate the string and add the dots for you, to a length specified through the variable length.
I haven't tested this, but it should work, any problems, let me know!
Edit: Works now XD
Thanks bunches Michael
Global footer.![]()
Ok it works almost too good
My menu buttons are gone.
Ok... So when I said all links it did just that XD and it really works, however I see a few instances where we should probably tell it not to shorten...
http://tfc.forums.us
Changeif(a[i].innerHTML.length > length)toif(a[i].innerHTML.length > length && !a[i].href.match(/forums\.us/))
That'll make it change all links except links to your forum.So menu should be unaffected.
![]()
Glad it's working.![]()