1.首先將它們拼成字符串 s 2.s=s.replace(/xml|\/xml|record|\/record/g,""); 3.alert(s) === script var s="xml" +"recordAISHUMIN,female,1976-08-06/record" +"recordANHONG,male,1976-09-06/record" +"recordANXIAOZHONG,female,1977-09-17/record" +"recordBAINING,female,1979-05-10/record" +"recordDONGDAIYU,male,1976-04-03/record" +"recordDONGZHAOQIANG,male,1978-07-22/record" +"recordFANGXIUZE,male,1972-04-11/record" +"recordFUSONGQIANG,male,1982-04-11/record" +"/xml" s=s.replace(/xml|\/xml|record|\/record/g,""); alert(s) /script

為平江等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及平江網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為做網(wǎng)站、網(wǎng)站設(shè)計(jì)、平江網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
常用的用
1)name/id。該屬性用于指定用來保存用戶輸入文本的變量和名稱。定義name/id屬性后WML將根據(jù)該屬性也即變量名,為即將輸入的文本實(shí)體對(duì)象與之存儲(chǔ)空間,以便接收用戶輸入。
2)title。該屬性用于input元素的標(biāo)簽,通常是位于輸入框前的提示信息。
3)type。用于指定文本輸入?yún)^(qū)的類型,有text和password兩種選擇。默認(rèn)值為text,指定的用戶可以輸入文本,而且輸入的文本會(huì)同時(shí)逐漸響應(yīng)并顯示在瀏覽器中。如果選擇password,則指定用戶輸入的文本作為密碼文本處理,WML程序按文本實(shí)體接收輸入的數(shù)據(jù),而瀏覽器上響應(yīng)用戶輸入顯示時(shí)逐漸均為星號(hào)(*),由此起到保密的目的。
4)value。該屬性用于指定name屬性所定義變量的值,它將顯示在輸入框中。
5)default。該屬性用于指定name屬性所定義變量的默認(rèn)值。
6)format。該屬性用于格式化輸入的數(shù)據(jù)。
7)maxlength。該屬性用于指定用戶可輸入字符串的最大長(zhǎng)度。該屬性的上限為256,最多不能超過256個(gè)字符。
8)emptyok。用于指定用戶是否可以不在輸入框內(nèi)輸入內(nèi)容。
9)size。該屬性用于指定輸入框的寬度,寬度值為字符個(gè)數(shù)。
10)tabindex。用于指定多個(gè)輸入框存在時(shí),類似于HTML中Tab鍵的具體位置。
等等等...
應(yīng)該說的是 Text 對(duì)象吧。就是 input type="text" / 這樣的 DOM 元素。
它的 form 屬性返回一個(gè)對(duì)包含文本域的表單對(duì)象的引用。舉個(gè)例子吧:
form
input?id="demo"?type="text"?/
/form
那么:
var?element?=?document.getElementById('demo').form;
就可以得到這個(gè) form 元素。
簡(jiǎn)單的說就是 Text 元素一般用在表單提交里,所以這個(gè)屬性是用來取得它所屬的表單的。
最簡(jiǎn)單的方法就是用元素的innerHTML屬性賦值,如:myNewElement.innerHTML = “我是文本”;但這樣不能清晰的體現(xiàn)DOM中新增加了一個(gè)文本節(jié)點(diǎn)。
然后另一種添加文本節(jié)點(diǎn)的方式,可分為兩步:
1、創(chuàng)建節(jié)點(diǎn):文本節(jié)點(diǎn)的創(chuàng)建使用createTextNode方法,如:var myText = document.createTextNode(“我是文本”);
2、將創(chuàng)建的節(jié)點(diǎn)用appendChild方法添加某個(gè)元素下。如:myNewElement.appendChild(myText);這樣myNewElement就有myText的文本節(jié)點(diǎn),文本節(jié)點(diǎn)的內(nèi)容是“我是文本”即可。
獲取屬性節(jié)點(diǎn)
第一種方法:獲取官方定義的屬性節(jié)點(diǎn)(獲取元素的對(duì)應(yīng)屬性值)。
格式:元素節(jié)點(diǎn),屬性名。
注意:不能獲取自定義屬性的值。
代碼如下:
console.log(jsInput.placeholder);
alert("是時(shí)候展現(xiàn)真正的技術(shù)");
設(shè)置屬性節(jié)點(diǎn)的值
公式:元素節(jié)點(diǎn) . 屬性名 = 新的屬性值
代碼如下:
//設(shè)置元素對(duì)應(yīng)屬性的值
//元素節(jié)點(diǎn).屬性名 = 新的屬性值
jsInput.placeholder = "sunck good";
第二種方法
公式:元素節(jié)點(diǎn) . getAttribute(屬性名);
注意:還可以獲取自定義屬性的值。
代碼:
console.log(jsInput.getAttribute("my"));
設(shè)置自定屬性的值
公式:元素節(jié)點(diǎn) . setAttribute(屬性名, 新屬性值);
注意:當(dāng)屬性不存在時(shí),變?yōu)樘砑訉傩?/p>
代碼:
//設(shè)置
//元素節(jié)點(diǎn).setAttribute(屬性名, 新屬性值);
jsInput.setAttribute("my", "sunck");
//注意:當(dāng)屬性不存在時(shí),變?yōu)樘砑訉傩?/p>
jsInput.setAttribute("other", "sunck");
刪除屬性節(jié)點(diǎn)
公式:元素節(jié)點(diǎn).removeAttribute(屬性名);
注意:某些低版本瀏覽器不支持
代碼:
jsInput.removeAttribute("other");
console.log(jsInput);
主要利用了setTimeout(),遞歸和String.substring();
做出的效果就像是有一個(gè)打字員在打字.
!doctype html
html lang="en"
head
meta charset="UTF-8"
meta name="Generator" content="EditPlus?"
meta name="Author" content=""
meta name="Keywords" content=""
meta name="Description" content=""
titleDocument/title
/head
body bgcolor="#ccc" onload="printer();"
h2 align="center"文本自動(dòng)輸出/h2
br
br
hr width="400" color="black"
br
form align="center"
textarea cols="50" rows="30" id="text" style="background-color:#FF99CC; color: #330033; cursor: default; font-family: Arial; font-size: 18px" wrap=virtual/textarea
/form
/body
script type="text/javascript"
//獲取textarea對(duì)象
var text=document.getElementById("text");
//要輸出的內(nèi)容
var str=" 傳統(tǒng)的HTML語言不能開發(fā)交互式的動(dòng)態(tài)網(wǎng)頁,而JavaScript卻能很好的做到這一點(diǎn)。JavaScript是一門相當(dāng)簡(jiǎn)單易學(xué)的網(wǎng)絡(luò)化編程語言,通過把她和HTML語言相互結(jié)合起來,能夠?qū)崿F(xiàn)實(shí)時(shí)的動(dòng)態(tài)網(wǎng)頁特效,這給網(wǎng)頁瀏覽者在瀏覽網(wǎng)頁的同時(shí)也提供了某些樂趣。";
var pos=0;
//利用遞歸和setTimeout()實(shí)現(xiàn)文字輸出
function printer(){
text.value=str.substring(0,pos)+"|";
//判斷是否到達(dá)結(jié)尾.如果是則一秒后再來一遍.
if(pos++str.length){
pos=0;
setTimeout("printer()",1000);
}else{
setTimeout("printer()",50);
}
}
/script
/html
方法二:JavaScript實(shí)現(xiàn)打字電腦打字效果
span id="demo"/span
script defer
var text="JavaScript實(shí)現(xiàn)的打字效果" //預(yù)定文字
var delay=200 //文字出現(xiàn)的時(shí)間間隔
var i=0 //初始化變量 i
function scrollit(){
//設(shè)置 id 為 demo 的對(duì)象內(nèi)的文字為從變量 text 的 0 開始到 i 間的文字加"_"
demo.innerText=text.slice(0,i++)+"_"
if(itext.length){ //當(dāng) i 大于 text 的文本長(zhǎng)度時(shí)
i=0 //重設(shè) i 為 0,使文字重新從第一個(gè)文字出現(xiàn)
//延時(shí)執(zhí)行scrollit()函數(shù),delay*10是為了讓顯示完整文字的時(shí)間長(zhǎng)一點(diǎn)
setTimeout("scrollit()",delay*10)
}
//否則在delay毫秒后再次執(zhí)行scrollit()函數(shù)
else setTimeout("scrollit()",delay)
}
scrollit() //調(diào)用scrollit()函數(shù)
/script
方法三:html xmlns=""
head
title標(biāo)題頁/title
script language=javascript
var layers =document.layers;
var style=document.all;
var both=layers||style;
var idme=908601;
if(layers)
{ layerRef='document.layers';styleRef ='';}
if(style)
{ layerRef='document.all';styleRef = '.style';}
//開始參數(shù)的定義
function writeOnText(obj,str)
{
if(layers)with(document[obj])
{ document.open();document.write(str);document.close();}
if(style)eval(obj+'.innerHTML=str');
}
var dispStr=new Array("證監(jiān)會(huì)稱將嚴(yán)查利用內(nèi)幕信息牟取不當(dāng)利益行為!"); //要出現(xiàn)的文本
var overMe=0;
//逐字顯示的方法
function txtTyper(str,idx,objId,objStyle,color1,color2,delay,plysnd)
{
var mystr='',strchar='';
var skip=200;
if (both idx=str.length) {
if (str.charAt(idx)==''){ while(str.charAt(idx)!='') idx++;}
if (str.charAt(idx)==''str.charAt(idx+1)!=' '){ while (str.charAt(idx)!= ';')idx++;}
mystr = str.slice(0,idx); //返回?cái)?shù)組從開始到指定位置的字符串
strchar = str.charAt(idx++);//當(dāng)前地址的字符
if (overMe==0 plysnd==1)
{
//針對(duì)瀏覽器的不同,調(diào)用不同的顯示方法
if (navigator.plugins[0]){
if(navigator.plugins["LiveAudio"][0].type=="audio/basic" navigator.javaEnabled())
{document.embeds[0].stop();
setTimeout("document.embeds[0].play(false)",100);}
} else if (document.all){
ding.Stop();
setTimeout("ding.Run()",100);}
overMe=1;}else overMe=0;
writeOnText(objId, "span class="+objStyle+"font color='"+color1+"'"+mystr+"/fontfont color='"+color2
+"'"+strchar+"/font/span");
setTimeout("txtTyper('"+str+"', "+idx+", '"+objId+"', '"+objStyle+"', '"+color1+"', '"+color2+"', "+delay+" ,"+plysnd+")",delay);}}
function init()
{txtTyper(dispStr[0], 0, 'div1', 'style1', '#66CCBB', '#000000', 400, 0);}
/script
BODY onload=init()
DIV class=style1 id=div1/DIV
/BODY
/html
呵呵,這個(gè)應(yīng)該可以的,你看看先
不過我只在IE上試過
文本文件這樣寫:
00.txt
::this is the 1st line:;
::this is the 2nd line:;
::this is the 3rd line:;
::this is the 4st line:;
::this is the 5st line:;
::this is the 6st line:;
::this is the 7st line:;
::this is the 8st line:;
::this is the 9st line:;
::this is the 10st line:;
::this is the 11st line:;
::this is the 12st line:;
::this is the 13st line:;
html里面這樣調(diào)用(與00.txt放在同一個(gè)文件夾里):
input type="button" onclick="get_line()" value="getline" /
script type="text/javascript"
var s;
var endl,beginl;
var strend;
var templ=new Array();
var n=0;
function onDone(txtData) {
s=txtData;
gettempl();
}
function getdata(url) {
document.body.addBehavior("#default#download");
document.body.startDownload(url,onDone);
}
function gettempl () {
while(s.indexOf("::")!=-1) {
beginl=parseInt(s.indexOf("::"))+2;
endl=parseInt(s.indexOf(":;"));
strend=s.length;
templ[n]=s.substring(beginl,endl);
s=s.substring(endl+2,strend);
n++;
}
}
function getline(obj) {
return templ[obj];
}
function get_line() {
alert(getline(0));
alert(getline(1));
alert(getline(2));
alert(getline(3));
alert(getline(4));
alert(getline(5));
alert(getline(6));
alert(getline(7));
alert(getline(8));
alert(getline(9));
alert(getline(10));
}
getdata('00.txt');
/script
呵呵,剛想到的,之前我也為這個(gè)為難過,后來另外定義了一個(gè)函數(shù),用數(shù)組來實(shí)現(xiàn)的。
希望這個(gè)對(duì)你有用。
網(wǎng)站名稱:javascript文本,javascript文本劃線
網(wǎng)站地址:http://chinadenli.net/article9/dsgooih.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、手機(jī)網(wǎng)站建設(shè)、品牌網(wǎng)站制作、網(wǎng)站改版、企業(yè)建站、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)