OZONE Asylum
Forums
DHTML/Javascript
Message Format
This page's ID:
28675
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
[code] /** * The following function will help to format messages in the client side. * Usage: * var s = "My name is {0}.\n\rI like {1}"; * alert(MessageFormat(s,"Yossi","JavaScript")); */ function StringFormatter(){ } StringFormatter.prototype.format = function(str) { var i = 1; while(i < arguments.length){ var delimiter = "{" + (i-1) + "}"; var pos = str.indexOf(delimiter); if(pos > -1){ var s = str.substring(0, pos) + arguments[i]; str = s + str.substring(pos + delimiter.length, str.length); } i++; } return str; } var MessageFormat = new StringFormatter(); [/code] Enjoy [small](Edited by [url=http://www.ozoneasylum.com/user/6365]Admon Yossi[/url] on 11-28-2006 08:53)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »