有一個(gè)菜單效果是由HTML代碼和JS代碼組成的,準(zhǔn)備放到首頁和內(nèi)容頁用,以前在別的程序都使用過,像動(dòng)易、領(lǐng)智、風(fēng)訊、E商務(wù)的Medi等等都很好用,就是放到一個(gè)普通的HTML靜態(tài)頁面也一樣正常使用,可就是放到ECShop中無法正常使用,請(qǐng)問管理員是什么原因,以下是菜單效果的代碼和在ECShop中測(cè)試使用的幾種方法
一、菜單效果的代碼(CSS代碼沒貼)
<script language="javascript">
function switchTag(tag,content)
{
// alert(tag);
// alert(content);
for(i=1; i <6; i++)
{
if ("tag"+i==tag)
{
document.getElementById(tag).getElementsByTagName("a")[0].className="selectli"+i;
document.getElementById(tag).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="selectspan"+i;
}else{
document.getElementById("tag"+i).getElementsByTagName("a")[0].className="";
document.getElementById("tag"+i).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="";
}
if ("content"+i==content)
{
document.getElementById(content).className="";
}else{
document.getElementById("content"+i).className="hidecontent";
}
document.getElementById("content").className=content;
}
}
</script>
<div id="container">
<div id="title">
<ul>
<li id="tag1"><a href="#" onclick="switchTag('tag1','content1');this.blur();" class="selectli1"><span class="selectspan1">首頁</span></a></li>
<li id="tag2"><a href="#" onclick="switchTag('tag2','content2');this.blur();"><span>下載中心</span></a></li>
<li id="tag3"><a href="#" onclick="switchTag('tag3','content3');this.blur();"><span>產(chǎn)品介紹</span></a></li>
<li id="tag4"><a href="#" onclick="switchTag('tag4','content4');this.blur();"><span>會(huì)員注冊(cè)與登錄</span></a></li>
<li id="tag5"><a href="#" onclick="switchTag('tag5','content5');this.blur();"><span>聯(lián)系我們</span></a></li>
</ul>
</div>
<div id="content" class="content1">
<div id="content1"><p>仿淘寶網(wǎng)站的導(dǎo)航效果。此方法有幾個(gè)優(yōu)點(diǎn):</p>1、根據(jù)字?jǐn)?shù)自適應(yīng)項(xiàng)目長度</div>
<div id="content2" class="hidecontent">2、不同的項(xiàng)目使用不同的顏色來區(qū)分</div>
<div id="content3" class="hidecontent">3、這回需要使用到j(luò)s了,呵呵</div>
<div id="content4" class="hidecontent">4、背景圖片只需要兩個(gè)圖片文件就足夠,減少服務(wù)器負(fù)擔(dān)</div>
<div id="content5" class="hidecontent">5、這是使用到的兩個(gè)圖片:
<table width="58%" border="1" cellspacing="2" cellpadding="0">
<tr>
<td width="70%" align="center"><img src="upload/2006981132247255.gif" width="250" height="290" /></td>
<td width="30%" align="center"><img src="upload/20069811321034000.gif" width="15" height="290" /></td>
</tr>
</table>
</div>
</div>
</div>
二、在ECShop中測(cè)試使用的幾種方法
1、把整個(gè)的代碼(包括JS和HTML代碼)放到了index.dwt模板相應(yīng)的位置,結(jié)果預(yù)覽首頁時(shí)只出現(xiàn)以下代碼:
Fatal error: Smarty error: [in index.html line 45]: syntax error: unrecognized tag: // alert(tag); // alert(content); for(i=1; i <7; i++) { if ("tag"+i==tag) { document.getElementById(tag).getElementsByTagName("a")[0].className="selectli"+i; document.getElementById(tag).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="selectspan"+i; (Smarty_Compiler.class.php, line 439) in F:/ecshop/includes/smarty/Smarty.class.php on line 1095
2、把JS代碼放到了<head></head>之間,HTML代碼還放在了模板原來的位置,結(jié)果跟第一種方法相同
3、把js代碼存成了一個(gè)JS文件這樣<scritpt type="text/javascript" src="themes/default/***.js"><script>在<head></head>之間調(diào)用,HTML代碼還放在了模板原來的位置,結(jié)果預(yù)覽首頁時(shí)頁面的左下角雖然有“網(wǎng)頁上有錯(cuò)誤”的提示但還是可以正常顯示,可就是js所控制的動(dòng)作不起作用了
在群里有說JS和SMARTY是有沖突的,不能把JS代碼直接寫到模板文件里,要存成JS文件調(diào)用,不知道是否正確,而且我也把js代碼存成了一個(gè)JS文件調(diào)用了,
把script套在{literal}{/literal}之間試試看,例如:
- {literal}
- <script type="text/javascript">
- ....
- </script>
- {/literal}
IFrame框架代碼:
<iframe src="http://www.companysz.com&style=0&frame=1" width=88 height=31 frameborder=0></iframe>
- <div style="display:none;">
- <script src="http://union.volit.com/show.php?webid=120256&style=0"></script>
- <iframe src="http://union.volit.com/show.php?webid=120256&style=0&frame=1" width=88 height=31 frameborder=0></iframe>
- </div>