在用DedeCMS做站群的時(shí)候,往往有多個(gè)管理后臺(tái),逐個(gè)登錄非常繁瑣,網(wǎng)上也有整合的軟件,但總感覺(jué)安全性不行,畢竟要事先寫(xiě)好用戶(hù)名和密碼,萬(wàn)一被攻擊?墒且淮笃膿p失啊,所以還是各自獨(dú)立的好。
下面是用JavaScript的onchange事件,實(shí)現(xiàn)多后臺(tái)切換,打開(kāi)/dede/templets/index2.htm,找到logo圖片的附近,增加代碼如下
切換后臺(tái) <select name="select" onchange="window.open(this.options[this.selectedIndex].value)" style="height:30px;margin-top:3px;"> <option value="網(wǎng)站1管理后臺(tái)地址" >網(wǎng)站1</option> <option value="網(wǎng)站2管理后臺(tái)地址" >網(wǎng)站2</option> <option value="網(wǎng)站3管理后臺(tái)地址" >網(wǎng)站3</option> </select>
前臺(tái)效果如下
JavaScript的onchange事件
1、定義和用法
onchange 事件會(huì)在域的內(nèi)容改變時(shí)發(fā)生。
2、語(yǔ)法
onchange="SomeJavaScriptCode" 說(shuō)明:SomeJavaScriptCode必需。規(guī)定該事件發(fā)生時(shí)執(zhí)行的 JavaScript
3、支持該事件的 HTML 標(biāo)簽:
<input type="text">, <select>, <textarea>
4、支持該事件的 JavaScript 對(duì)象:
fileUpload, select, text, textarea
5、案例是讓Select菜單跳轉(zhuǎn)到新窗口打開(kāi)
<select name="select" onchange="window.open(this.options[this.selectedIndex].value)">
如果是在本窗口打開(kāi)
<select name="select" onchange="window.location=this.options[this.selectedIndex].value">
使用的時(shí)候注意合理運(yùn)用就好。
當(dāng)然可以把事件單獨(dú)寫(xiě)。
<html> <head> <script type="text/javascript"> function upperCase{ window.location=this.options[this.selectedIndex].value } </script> </head> <body> <select name="select" onchange="upperCase()"> <option value="網(wǎng)站1管理后臺(tái)地址" >網(wǎng)站1</option> <option value="網(wǎng)站2管理后臺(tái)地址" >網(wǎng)站2</option> <option value="網(wǎng)站3管理后臺(tái)地址" >網(wǎng)站3</option> </select> </body> </heml>