string js function interception

2009-07-21  来源:本站原创  分类:AJAX  人气:333 

function countCharacters (str, size) (
var totalCount = 0;
var newStr = "";
for (var i = 0; i <str.length; i + +) (
var c = str.charCodeAt (i);
if ((c> = 0x0001 & & c <= 0x007e) | | (0xff60 <= c & & c <= 0xff9f)) (
totalCount + +;
) else (
totalCount + = 2;
)
if (totalCount <size) (
newStr = str.substring (0, i +1);
) else (
return newStr +"...";
)
)
return newStr;
)

相关文章
  • string js function interception 2009-07-21

    function countCharacters (str, size) ( var totalCount = 0; var newStr = ""; for (var i = 0; i <str.length; i + +) ( var c = str.charCodeAt (i); if ((c> = 0x0001 & & c <= 0x007e) | | (0xff60 <= c & & c <= 0xff9f)) (

  • string js function expansion 2009-11-06

    Source: http://www.phpweblog.net/kiyone/archive/2007/04/19/1135.aspx Encyclopedia of string manipulation functions Js / * ****************************************** String function expansion ****************************************** * / / * ========

  • EL expression string correlation function interception 2011-01-10

    Can be intercepted, with the fn function: <% @ Taglib prefix = "fn" uri = " http://java.sun.com/jsp/jstl/functions "%> The following is a list of JSTL in native methods and their descriptions Help using the example function name

  • String function interception 2010-07-27

    Write a string function interception, enter the number of bytes to a string and output string for the interception by byte, but characters will not be intercepted to ensure a half, such as "I ABC", 4, should interception "I AB ", type&

  • JS string replace function replaces all the way 2010-09-05

    JS string replace function: Replace ("string 1", "String 2") 1. We all know JS string replace function is Replace ("string 1", "String 2"), but this function can only be the first time replacing the string 1, then h

  • js in English and Chinese in English and Chinese string length of the string js intercept (change) 2010-03-30

    js in English and Chinese in English and Chinese string length of the string js intercept (change) Keywords: javascript / Interception Abstract: We have procedures for dealing with the process of the text, often encounter problems in English and Chin

  • Practical js Function 2009-10-15

    Recommend practical js function: // Open the pop-up window function winOpen (strURL,strName,width,height) { theWindow = window.open (strURL,strName,"width="+width+" height="+height+" scrollbars=yes left="+(1024-width)/2+"

  • Some classical string hash function 2010-08-19

    The article is excerpted from the transition http://www.cmykrgb123.cn/blog/string-hash-compare/ Commonly used string Hash functions ELFHash,APHash Etc., are very simple and efficient way . These functions use the Bitwise operation makes each characte

  • Php string handling function to explain 2010-10-22

    addcslashes - the inside part of the character string to add the backslash escape character addslashes - the manner specified character inside the string to escape bin2hex - the binary data into hexadecimal representation chr - Return a character's A

  • remove spaces string js 2010-12-14

    1, the regular expression / / Go left blank; function ltrim (s) ... { return s.replace (/ (^ s *) / g, ""); } / / Go to the right space; function rtrim (s) ... { return s.replace (/ (s * $) / g, ""); } / / To influence the space; funct

  • Chinese string PHP Methods interception (to) 2010-12-21

    Process a: PHP interception Chinese string method in the Home and vTigerCRM often garbled interception Chinese string (using substr), today to find a better method for the interception of Chinese string, in this and share. function msubstr ($ str, $

  • JS function scope and closures 2010-12-22

    JS function scope and closures JS function scope: to divide through the lexical scope, rather than dynamically scoped, which means that they define the scope of his to run, not in the scope of the implementation of his to run. When defining a functio

  • javascript Dom worthy collection js function 2009-05-10

    / / Commonly used JS, at page load after the implementation of JS. function addLoadEvent (func) ( var oldonload = window.onload; if (typeof window.onload! = 'function') ( window.onload = func; ) Else ( window.onload = function () ( oldonload (); func

  • . Net control the postback control is controlled by the js function 2010-02-11

    . Net control the postback control is controlled by the js function: <script language="javascript" type="text/javascript"> <!-- function __doPostBack(eventTarget, eventArgument) { var theform; if (window.navigator.appName.toLo

  • js function of how to achieve download ah 2010-04-09

    js function of how to achieve download ah

  • Sub page call JS function IFRAME 2010-05-27

    Sub-page called IFRAME JS function 2009-10-15 19:02 Description: Suppose there are 2 pages, index.html and inner.html. Index.html which has a iframe, the iframe's src points to inner.html. We now have to do is: 1. Inner.html called index.html on a js

  • js function overloading 2010-06-02

    t.js function t(){ run(); } a.js function run(){ alert("a.js"); } b.js function run(){ alert("b.js"); } Would like to pop a.js, call a.js, t.js on the line Would like to pop b.js, call b.js, t.js on the line

  • js function of the parameters of the problem 2010-06-11

    The function of JS, I believe we already understand, some of which feature it, feel it is worthwhile to mention, the following JS function in the talk about it. First of all, JS is also an identifier in the function, it can be assigned to a new varia

  • PHP common string partition function is then replaced and the comparison 2010-06-26

    PHP is commonly used in this paper is the distinction between matching function, mainly str_replace, str_ireplace, substr_replace, preg_replace, preg_match, preg_match_all, preg_quote, preg_split, ereg_replace, eregi_replace, preg_replace, str_split,

  • js function in the browser is compatible under 2010-06-30

    Do front-end development of engineers, ultimately, to use FF for testing, pure js function in different browsers, the name may be different. For IE6 and FF, to obtain the next node on the different functions: IE6: node.nextSibling, the FF can not be