10/10/2018, 10:48
Giúp đỡ code javascript
Mình đang làm một website có sử dụng module thời tiết, tỷ giá. Demo tại đây http://vccicantho.edu.vn/utxivn/ .
Mặc định phần Thời tiết, Tỷ giá và Giá vàng tự xổ ra khi load trang, click vào dấu + thì nó sẽ thu lại .
Bây giờ mình muốn sửa code cho nó thu lại mặc định và xổ ra khi ta bấm vào dấu + .
Đã xăm soi cái file js nhưng mà ko mò được. Bạn nào biết giúp mình với nhé. Dưới đây là mã của file Lib.js .
thanks
Mặc định phần Thời tiết, Tỷ giá và Giá vàng tự xổ ra khi load trang, click vào dấu + thì nó sẽ thu lại .
Bây giờ mình muốn sửa code cho nó thu lại mặc định và xổ ra khi ta bấm vào dấu + .
Đã xăm soi cái file js nhưng mà ko mò được. Bạn nào biết giúp mình với nhé. Dưới đây là mã của file Lib.js .
Code:
var fBrw=(navigator.userAgent.indexOf('MSIE')!= -1 && navigator.userAgent.indexOf('Windows')!= -1); var fDSp=(typeof(document.getElementById)!='undefined'); var RefBanner = new Array(); var RefAdLogo = new Array(); var RefAdLBox = new Array(); var RefAdLBar = new Array(); var RefColumn = new Array(); var RefAdLeft = new Array(); var RefURight = new Array(); var RefUColum = new Array(); var RefDRight = new Array(); var RefDiLeft = new Array(); var RefFlLeft = new Array(); var RefAtDate = new Array(); var RefAtQuan = new Array(); var RefAPopup = new Array(); var RefUPopup = new Array(); var RefNormal = new Array(); var RefExpand = new Array(); var LastChild = 0; var LComplete = 0; if (typeof(PageHost) == 'undefined') var PageHost = '; var objXML; var aFlag=true; function loadXMLDoc(url, callbackFunction, desc, QUERY_STRING) { aFlag=false; if(desc) window.status = desc; // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { objXML = new XMLHttpRequest(); objXML.onreadystatechange = function() { // only if req shows "complete" if (objXML.readyState == 4) { eval(callbackFunction); } } if(QUERY_STRING) { objXML.open("POST", url, true); objXML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); objXML.send(QUERY_STRING); } else { objXML.open("GET", url, true); objXML.send(null); } // branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { objXML = new ActiveXObject("Microsoft.XMLHTTP"); if (objXML) { objXML.onreadystatechange = function() { // only if req shows "complete" if (objXML.readyState == 4) { eval(callbackFunction); } } if(QUERY_STRING) { objXML.open("POST", url, true); objXML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); objXML.send(QUERY_STRING); } else { objXML.open("GET", url, true); objXML.send(null); } } } } function AddBreakSpace(Pixel) { if (typeof(Pixel)=='undefined') { Pixel=3; } document.writeln('<table cellspacing=0 cellpadding=0 border=0 width="100%" bgcolor="#FFFFFF"><tr><td height=', Pixel, '><img src="/Images/White.gif" border=0 height=1 width=1></td></tr></table>'); } function AddHeader(Name, Header, Buttons, Symbol, AddChildTable) { document.writeln('<table width="100%" border=0 cellspacing=0 cellpadding=1 class="title_forex"><tr><td>'); if (Header!=') { document.writeln('<table width="100%" border=0 cellspacing=0 cellpadding=0>'); document.writeln('<tr>'); if (typeof(Symbol)!='undefined') { document.writeln('<td height=16 class=BoxHeader><img src="', Symbol, '" border=0></td>'); } document.writeln('<td height=16 width="100%" align=left class=BoxHeader> ', Header, '</td>'); if ((Buttons & 1) && fDSp) { document.write('<td width=15 align=right>'); document.write('<a href="JavaScript:ItemMinimize(x27', Name, 'x27)">'); document.write('<img src="'+theme+'minus.gif" name="IDI_', Name, '" border=0 alt="Xem|Đóng">'); document.write('</a></td>'); } document.writeln('</tr></table>'); } //document.writeln('<table width="100%" border=0 cellspacing=0 cellpadding=0 id="tIDM_', Name, '"><tr><td><div class=BreakLine id="IDM_', Name, '">'); document.writeln('<table width="100%" border=0 cellspacing=0 cellpadding=0><tr><td id="IDM_', Name, '">'); if (typeof(AddChildTable)=='undefined') { document.writeln('<table align=center width="100%" cellspacing=0 cellpadding=0 border=1>'); LastChild = 1; } else { LastChild = 0; } return true; } function AddFooter() { if (LastChild) { document.writeln('</table></td></tr></table></td></tr></table>'); } else { document.writeln('</td></tr></table></td></tr></table>'); } } function ItemMinimize(Name) { if (!fDSp) { return; } var MItem=document.getElementById('IDM_'.concat(Name)); var Image=document.getElementById('IDI_'.concat(Name)); if (MItem.style.display!=') { //MItem.setAttribute('style','display:""'); MItem.style.display='; Image.src=theme+'minus.gif'; } else { //MItem.setAttribute('style','display:none'); MItem.style.display='none'; Image.src=theme+'plus.gif'; } } function SetParameter(pFile, pName, pVal) { if ((cPost=pFile.indexOf('&'.concat(pName).concat('=')))==-1) cPost=pFile.indexOf('?'.concat(pName).concat('=')); if (cPost >= 0) { if ((pPost=pFile.indexOf('&', cPost + 1))==-1) { pFile=pFile.substring(0, cPost + pName.length + 2).concat(pVal); } else { pFile=pFile.substring(0, cPost + pName.length + 2).concat(pVal).concat(pFile.substr(pPost)); } } else { if (pFile.indexOf('?')==-1) { pFile=pFile.concat('?').concat(pName).concat('=').concat(pVal); } else { pFile=pFile.concat('&').concat(pName).concat('=').concat(pVal); } } return pFile; } function ReverseFolderByDate() { Ryear = document.Reverse.fYear.options[document.Reverse.fYear.selectedIndex].value; Rmonth = document.Reverse.fMonth.options[document.Reverse.fMonth.selectedIndex].value; Rday = document.Reverse.fDay.options[document.Reverse.fDay.selectedIndex].value; for (; Rday > 0; Rday--) { Rdate = new Date(Ryear, Rmonth - 1, Rday); if (Rdate.getDate() == Rday) { break; } } LastDate = Ryear.concat('/').concat(Rmonth).concat('/').concat(Rday).concat(' 23:59:59'); if (RelatedFolder < 1000 ) { location.replace(CurrentFolder.concat('/Default.Asp?d=').concat(escape(LastDate))); } else { location.href = SetParameter(location.href, 'd', escape(LastDate)); } } function ShowNextFolderItem(LastDate) { if (RelatedFolder < 1000 ) { location.href = SetParameter(location.href + 'Default.Asp', 'd', escape(LastDate)); } else { location.href = SetParameter(location.href, 'd', escape(LastDate)); } } function UnderConst() { alert('Sorry! This Page is under construction! Please try latter!'); } function openMe(url, inNew, winDef) { if (url == ') return; if (typeof(inNew)=='undefined') inNew = 0; if (typeof(winDef)=='undefined') winDef = 'scrollbars=yes,status=yes,toolbar=yes,location=yes,menubar=yes,resizable=yes,height=300,width=400,top='.concat((screen.height - 400)/2).concat(',left=0'); if (inNew) { open(url, 'Advertising', winDef); } else { location.href = url; } } function openImage(vLink, vHeight, vWidth) { var sLink = (typeof(vLink.href) == 'undefined') ? vLink : vLink.href; if (sLink == ') { return false; } winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(','); winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(','); winDef = winDef.concat('left=').concat((screen.width - vWidth)/2); newwin = open(', '_blank', winDef); newwin.document.writeln('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">'); newwin.document.writeln('<a href="" onClick="window.close(); return false;"><img src="', sLink, '" alt="', (fBrw) ? 'Đ***243;ng lại' : 'Dong lai', '" border=0></a>'); newwin.document.writeln('</body>'); if (typeof(vLink.href) != 'undefined') { return false; } } function SetFont() { if (fBrw) { rs=window.showModalDialog('/SetFont.htm', ', 'dialogHeight:215px;dialogWidth:385px;status:no;help:no'); if (typeof(rs)!='undefined') { if (rs) { location.reload(true); } } } else { open('/SetFont.htm', 'SetFont', 'toolbar=no,height=185,width=370,top='.concat((screen.height - 185)/2).concat(',left=').concat((screen.width - 370)/2)); } } function PageSet(vPage) { location.replace(SetParameter(location.href, 'p', vPage)); } function UnicodeSet(iStr) { for (i=0, oStr='; i < iStr.length; i++) { switch ((j=iStr.charCodeAt(i))) { case 34: oStr=oStr.concat('"'); break; case 38: oStr=oStr.concat('&'); break; case 39: oStr = oStr.concat('***39;'); break; case 60: oStr = oStr.concat('<'); break; case 62: oStr = oStr.concat('>'); break; default: if (j < 32 || j > 127 || j==34 || j==39) { oStr=oStr.concat('***').concat(j).concat(';'); } else { oStr=oStr.concat(iStr.charAt(i)); } break; } } return oStr; } function UnicodeGet(iStr) { for (i=0, oStr='; i < iStr.length; ) { if (iStr.charCodeAt(i)==38) { if (iStr.charCodeAt(i + 1)==35) { p=iStr.indexOf(';', i + 2); if (p!=-1) { if (p - i <= 7) { if (isFinite(iStr.substr(i + 2, p - i - 2))) { oStr = oStr.concat(String.fromCharCode(iStr.substr(i + 2, p - i - 2))); i = p + 1; continue; } } } } else { p=iStr.indexOf(';', i + 1); if (p!=-1) { switch (iStr.substr(i + 1, p - i - 1)) { case 'amp': oStr = oStr.concat('&'); i = p + 1; break; case 'quot': oStr = oStr.concat('"'); i = p + 1; break; case 'lt': oStr = oStr.concat('<'); i = p + 1; break; case 'gt': oStr = oStr.concat('>'); i = p + 1; break; } } } } oStr=oStr.concat(iStr.charAt(i)); i++; } return oStr; } function SearchMe(s, a) { while (s.length > 0 && s.charAt(0) <= ' ') { s = s.substr(1); } while ((i=s.length) > 0 && s.charAt(i - 1) <= ' ') { s = s.substr(0, i - 1); } if (s==') { document.Search.TSearch.value = s; return false; } f = GetPostVariable('r', RelatedFolder); s = escape(UnicodeSet(s)); r = '/Search/?p=1&r='.concat(f).concat('&a=').concat(a).concat('&s=').concat(s); if (location.pathname.toLowerCase()=='/search/') { location.replace(r); } else { location.href=r; } return false; } function SearchOnFocus(field) { if(field.value=='Search') { field.value = '; } } function SearchOnBlur(field) { if(field.value==') { field.value='Search'; } } function ShowSearch() { if ((s=GetPostVariable('s', '))!=') { s = unescape(s); } s=UnicodeGet(s); document.writeln('<table height=30 cellspacing=0 cellpadding=0 border=0 align=center>'); document.writeln('<form method="POST" name="Search" onSubmit="return SearchMe(document.Search.TSearch.value, 1)">'); document.writeln('<tr>'); document.writeln('<td><div><input type="text" name="TSearch" size=9 value="Search" class=SearchBox onfocus="SearchOnFocus(this)" onkeyup="initTyper(this)" onblur="SearchOnBlur(this)"></div></td>'); document.writeln('<td class=BreakLine width=3> </td>'); document.writeln('<td><a href="javascript:SearchMe(document.Search.TSearch.value, 1)"><img src="/Images/Go.gif" border=0></a></td>'); document.writeln('</tr>'); document.writeln('</form>'); document.writeln('</table>'); if (s!=') { document.Search.TSearch.value = s; } } function CheckThisVote(field) { form = field.form; if (field.checked) { form.fvotefor.value = field.value; } else { form.fvotefor.value = '; return; } for (i=0; i < form.elements.length - 2; i++) { if(form.elements[i].type=='checkbox') if (form.elements[i] != field) if (form.elements[i].checked) form.elements[i].checked = false; } } function AddVote(SubjectID, PageID, VoteID, Align, VoteTitle, Color, BgColor, Width, NumItem, ItemArray, Description, Column) { if (RelatedFolder!=500){ document.writeln('<table width="', Width, '" border=0 cellspacing=0 cellpadding=2 bgcolor="', BgColor, '"', (Align==') ? ' : ' align='.concat(Align), '>'); if (VoteTitle!=') { document.writeln('<tr><td><p class=BoxTitle style="margin-left: 3; color: ', Color, '">', VoteTitle, '</p></td></tr>'); } if (typeof(Description)=='undefined') { Description = '; } if (typeof(Column)=='undefined') { Column = 1; } document.writeln('<tr>'); document.writeln('<form method="POST" target="Frm_', VoteID, '" name="Frm_', VoteID, '">'); document.writeln('<td>'); document.writeln('<table border=0 cellpadding=0 cellspacing=0 width="100%" bgcolor="#FFFFFF">'); document.writeln('<input type="hidden" name="fsubjectid" value=', SubjectID, '>'); document.writeln('<input type="hidden" name="fpageid" value=', PageID, '>'); document.writeln('<input type="hidden" name="ffolder" value="', CurrentFolder, '">'); document.writeln('<input type="hidden" name="fvoteid" value=', VoteID, '>'); document.writeln('<input type="hidden" name="fvotetitle" value="', ReplaceAll(VoteTitle, '"', '"'), '">'); document.writeln('<input type="hidden" name="fvotefor" value="">'); document.writeln('<input type="hidden" name="faction" value="0">'); document.writeln('<input type="hidden" name="fDescription" value="', ReplaceAll(Description, '"', '"'), '">'); document.writeln('<input type="hidden" name="fnumitem" value=', NumItem, '>'); document.writeln('<tr><td width="100%" height=5><img src="/Images/White.gif" border=0></td></tr>'); document.writeln('<tr><td>'); document.writeln('<table width="100%" cellspacing=0 cellpadding=0 border=0>'); var i, j, k; for (i=0; i < NumItem; ) { document.writeln('<tr>'); for (j=0; j < Column && i < NumItem; j++, i++) { document.writeln('<input type="hidden" name="fT_', i, '" value="', ReplaceAll(ItemArray[i][0], '"', '"'), '">'); document.writeln('<input type="hidden" name="fI_', i, '" value="', ItemArray[i][1], '">'); document.writeln('<input type="hidden" name="fN_', i, '" value="', ItemArray[i][2], '">'); document.writeln('<td valign=top width=20 align=right><input type="checkbox" name="fC_', i, '" value=', ItemArray[i][2], ' class=VoteField onClick="CheckThisVote(this)"></td>'); if (i + 1 < NumItem || Column==1) { document.writeln('<td><p class=VoteItem>', ItemArray[i][0], '</p></td>'); } else { document.writeln('<td colspan=', (Column - j - 1)*2,'><p class=VoteItem>', ItemArray[i][0], '</p></td>'); } } document.writeln('</tr>'); } document.writeln('</table>'); document.writeln('</td></tr>'); document.writeln('<tr><td width="100%" class=BreakLine height=4> </td></tr>'); document.writeln('<tr><td width="100%" class=BreakLine height=1 bgcolor="', BgColor, '"></td></tr>'); document.writeln('<tr><td width="100%" height=32> <input type="button" value="Biểu quyết" name="Vote" class=VoteButton style="width: 60" onClick="SubmitVote(this.form, 0)"> <input type="button" value="Kết quả" name="View" class=VoteButton style="width: 60" onClick="SubmitVote(this.form, 1)"></td></tr>'); document.writeln('</table>'); document.writeln('</td>'); document.writeln('</form>'); document.writeln('</tr>'); document.writeln('</table>'); document.writeln('<table height=2 cellspacing=0 cellpadding=0 border=0><tr><td class=BreakLine> </td></tr></table>'); } else{ document.writeln('<table width="90%" border=0 cellspacing=0 cellpadding=0 align=center bgcolor=white>'); document.writeln('<tr><td><img src="/Images/Motor-show/VoteTopLeft.gif"></td><td width=100%></td><td><img src="/Images/Motor-show/VoteTopRight.gif"></td></tr>'); if (VoteTitle!=') { document.writeln('<tr><td></td><td><p class=BoxTitle style="margin-left: 3; color: #113868">', VoteTitle, '</p></td><td></td></tr>'); } if (typeof(Description)=='undefined') { Description = '; } if (typeof(Column)=='undefined') { Column = 1; } document.writeln('<tr><td></td>'); document.writeln('<form method="POST" target="Frm_', VoteID, '" name="Frm_', VoteID, '">'); document.writeln('<td>'); document.writeln('<table border=0 cellpadding=0 cellspacing=0 width="100%" bgcolor="#FFFFFF">'); document.writeln('<input type="hidden" name="fsubjectid" value=', SubjectID, '>'); document.writeln('<input type="hidden" name="fpageid" value=', PageID, '>'); document.writeln('<input type="hidden" name="ffolder" value="', CurrentFolder, '">'); document.writeln('<input type="hidden" name="fvoteid" value=', VoteID, '>'); document.writeln('<input type="hidden" name="fvotetitle" value="', ReplaceAll(VoteTitle, '"', '"'), '">'); document.writeln('<input type="hidden" name="fvotefor" value="">'); document.writeln('<input type="hidden" name="faction" value="0">'); document.writeln('<input type="hidden" name="fDescription" value="', ReplaceAll(Description, '"', '"'), '">'); document.writeln('<input type="hidden" name="fnumitem" value=', NumItem, '>'); document.writeln('<tr><td width="100%" height=5><img src="/Images/White.gif" border=0></td></tr>'); document.writeln('<tr><td>'); document.writeln('<table width="100%" cellspacing=0 cellpadding=0 border=0>'); var i, j, k; for (i=0; i < NumItem; ) { document.writeln('<tr>'); for (j=0; j < Column && i < NumItem; j++, i++) { document.writeln('<input type="hidden" name="fT_', i, '" value="', ReplaceAll(ItemArray[i][0], '"', '"'), '">'); document.writeln('<input type="hidden" name="fI_', i, '" value="', ItemArray[i][1], '">'); document.writeln('<input type="hidden" name="fN_', i, '" value="', ItemArray[i][2], '">'); document.writeln('<td valign=top width=20 align=right><input type="checkbox" name="fC_', i, '" value=', ItemArray[i][2], ' class=VoteField onClick="CheckThisVote(this)"></td>'); if (i + 1 < NumItem || Column==1) { document.writeln('<td><p class=VoteItem>', ItemArray[i][0], '</p></td>'); } else { document.writeln('<td colspan=', (Column - j - 1)*2,'><p class=VoteItem>', ItemArray[i][0], '</p></td>'); } } document.writeln('</tr>'); } document.writeln('</table>'); document.writeln('</td></tr>'); document.writeln('<tr><td width="100%" class=BreakLine height=4> </td></tr>'); document.writeln('<tr><td width="100%" class=BreakLine height=1 bgcolor="', BgColor, '"></td></tr>'); document.writeln('<tr><td width="100%" height=32> <input type="button" value="Biểu quyết" name="Vote" class=VoteButton style="width: 60" onClick="SubmitVote(this.form, 0)"> <input type="button" value="Kết quả" name="View" class=VoteButton style="width: 60" onClick="SubmitVote(this.form, 1)"></td></tr>'); document.writeln('</table>'); document.writeln('</td>'); document.writeln('</form>'); document.writeln('<td></td></tr>'); document.writeln('<tr><td><img src="/Images/Motor-show/VoteBottomLeft.gif"></td><td width=100%></td><td><img src="/Images/Motor-show/VoteBottomRight.gif"></td></tr>'); document.writeln('</table>'); document.writeln('<table height=10 cellspacing=0 cellpadding=0 border=0><tr><td class=BreakLine> </td></tr></table>'); } } function Showsurvey(){ vWH = 500; vWW = 440; vWN = 'ContactUs'; winDef = 'status=no,resizable=no,scrollbars=yes,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vWH).concat(',').concat('width=').concat(vWW).concat(','); winDef = winDef.concat('top=').concat((screen.height - vWH)/2).concat(','); winDef = winDef.concat('left=').concat((screen.width - vWW)/2); newwin = open('/Customize/ADSLSurvey/', vWN, winDef); } function ShowExpand(sobj1, sobj2) { sobj1.style.display = 'none'; sobj2.style.display = '; } function SetSelectValue(Field, iStr) { if (iStr==') { iStr=' '; } for (i=0; i < Field.options.length; i++) { if (Field.options[i].value==iStr) { Field.selectedIndex=i; return; } } } function LTrim(iStr) { while (iStr.charCodeAt(0) <= 32) { iStr=iStr.substr(1); } return iStr; } function RTrim(iStr) { while (iStr.charCodeAt(iStr.length - 1) <= 32) { iStr=iStr.substr(0, iStr.length - 1); } return iStr; } function Trim(iStr) { while (iStr.charCodeAt(0) <= 32) { iStr=iStr.substr(1); } while (iStr.charCodeAt(iStr.length - 1) <= 32) { iStr=iStr.substr(0, iStr.length - 1); } return iStr; } function Left(str, n) { if (n <= 0) return ""; else if (n > String(str).length) return str; else return String(str).substring(0,n); } function Right(str, n) { if (n <= 0) return ""; else if (n > String(str).length) return str; else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } } function CheckEmailAddress(Email) { Email = Trim(Email); while (Email != ') { c = Email.charAt(0); if (c==' ' || c=='<' || c==39 || c==':' || c=='.') { Email = Email.substr(1); } else { break; } } i = Email.indexOf('>'); if (i==-1) { while (Email != ') { c = Email.charAt(Email.length - 1); if (c==' ' || c==39 || c=='.') { Email = Email.substr(0, Email.length - 1); } else { break; } } } else { Email = Email.substr(0, i); } if (Email.length > 96) return '; i = Email.lastIndexOf('@'); j = Email.lastIndexOf('.'); if (i < j) i = j; switch (Email.length - i - 1) { case 2: break; case 3: switch (Email.substr(i)) { case '.com': case '.net': case '.org': case '.edu': case '.mil': case '.gov': case '.biz': case '.pro': case '.int': break; default: return '; } break; default: switch (Email.substr(i)) { case '.name': case '.info': break; default: return '; } break; }
Bài liên quan
[=========> Bổ sung bài viết <=========]
Nhìn có vẻ quá dài nhưng đây là cái Function: ItemMinimize
[=========> Bổ sung bài viết <=========]
Đây là đoạn code gọi cái Function đó:
demo: http://vccicantho.edu.vn/utxivn/
Mở file Gold.js, thêm dòng:
Trong hàm AddHeader(), tìm dòng:
working well .
all the best to you .