081223
Forum discussion address:
Http://topic.csdn.net/u/20081223/10/dc553644-1580-46fb-8317-99d19909c574.html? Seed = 293528674
- <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <HTML xmlns = "http://www.w3.org/1999/xhtml">
- <Head>
- <Title> JavaScript syntax learning </title>
- <SCRIPT type = "text/JavaScript">
- Function f (){
- VaR STR = '1, 2, 3, 4 ';
- VaR str1 = '1, 4, 5, 6 ';
- STR = ',' + STR + ',';
- For (VAR I = 0; I <str1.length; I ++)
- {
- VaR c = str1.charat (I); // obtain char based on position
- If (C! = ',')
- {
- If (Str. indexof (',' + C + ',') <0) // if not found, insert C,
- {
- STR + = C + ',';
- }
- Else
- {
- Strstr = Str. Replace (',' + C + ','); // If yes, replace C,
- }
- }
- }
- Strstr = Str. substring (1, str. Length-1); // remove the last number.
- Alert (STR );
- }
- Document. onclick = function (){
- F ();
- }
- </SCRIPT>
- </Head>
- <Body>
- </Body>
- </Html>
End