移到這邊來之後,第一個遇上的問題是:用習慣了無名的好友功能。
網路上有解決之道,主要是某站去解析無名好友功能的程式碼,而後提供使用者隨意貼……。也幸好這邊可以自己增加外掛,所以貼些JavaScript倒不成問題。但是,我想要其他的好友也可以這樣選,有些好友使用無名,有些使用天空部落,有些使用樂多,怎麼辦呢?說不得,自己動手改一段了。
附上程式碼,修改方式應不致太難才是。
=====以下是程式碼=====
<script language="javascript">
function Person (nickname, address) {
this.nickname = nickname;
this.address = address;
}
friendType = new Array();
friend = new Array();
friend[0] = "";
//
// 更改的地方三
// 與更改的地方一相同
// 影響顯示的類別
// 附:好吧,其實這邊影響沒這麼大,主要是數字要對應得到。
//
friendType[0] = "請選擇";
friendType[1] = "東光國小";
friendType[2] = "中正國中";
friendType[3] = "東華補習班";
friendType[4] = "台北商專";
friendType[5] = "雲科二技";
typeLength = friendType.length;
//initial the 2nd. dimantion.
for (var i = 0; i < typeLength; i ++) {
friend[i] = new Array();
//friend[i][0] = friendType[i];
friend[i].push(new Person("請選擇", true));
}
//
// 更改的地方二
// 與上方的friendType的索引值需一樣
// 格式:暱稱 + 鏈結網址
// 餘此類推
//
//東光國小
friend[1].push(new Person("Das Kind", "http://ichbinkind.blogspot.com/"));
//中正國中
friend[2].push(new Person("DAS KIND", "http://ichbinkind.blogspot.com/"));
//東華補習班
friend[3].push(new Person("Kind", "http://ichbinkind.blogspot.com/"));
//台北商專
friend[4].push(new Person("Bear", "http://ichbinkind.blogspot.com/"));
//雲科二技
friend[5].push(new Person("DirtyBear", "http://ichbinkind.blogspot.com/"));
function goToAddress (address) {
//
if(address == true) {
return false;
} else {
window.open(address, "_blank");
}
}
function changeFriend(key) {
f = window.document.ff;
l = friend[key].length;
f.friendName.length = l;
for (var i = 0; i < l; i ++ ) {
f.friendName.options[i].value = friend[key][i].address;
f.friendName.options[i].text = friend[key][i].nickname;
}
f.friendName.options[0].selected = true;
}
function initialFriendType(f) {
f.friendType.length = typeLength;
for (var i = 0; i < typeLength; i ++ ) {
f.friendType.options[i].value = i;
f.friendType.options[i].text = friendType[i];
}
f.friendType.options[0].selected = true;
}
</script>
<form name="ff">好友分類
<select onchange="changeFriend(this.value)" name="friendType">
<!--顯示的類別
更改的地方一
依需求,加入自己需要的分類項瞥
VALUE依序編號即可
-->
<option value="0"/>請選擇
<option value="1"/>東光國小
<option value="2"/>中正國中
<option value="3"/>東華補習班
<option value="4"/>台北商專
<option value="5"/>雲科二技
</select><br/>好友暱稱
<select onchange="goToAddress(this.value)" name="friendName">
<option/>請選擇
</select>
</form>
=====以上是程式碼=====
程式碼參考自
中華郵政及
無名小站

This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 License.