本文收錄 BBS 系統關鍵 JavaScript 與 PHP 模組片段,包含浮動選單定位、資料庫連線封裝。
function KB_keepItInIE(theName, theWantTop, theWantLeft) {
theRealTop = parseInt(document.body.scrollTop);
theTrueTop = theWantTop + theRealTop;
document.all[theName].style.top = theTrueTop;
theRealLeft = parseInt(document.body.scrollLeft);
theTrueLeft = theWantLeft + theRealLeft;
document.all[theName].style.left = theTrueLeft;
}
function KB_keepItInNN(theName, theWantX, theWantY) {
theRealLay = document.layers[theName];
theBadX = self.pageYOffset;
theBadY = self.pageXOffset;
theRealX = theBadX + theWantX;
theRealY = theBadY + theWantY;
theRealLay.moveTo(theRealY, theRealX);
}
IE4 = (document.all) ? 1 : 0;
NN4 = (document.layers) ? 1 : 0;
// setInterval 範例已註解
支援 IE4+ (document.all) 與 NN4 (document.layers) 雙模式,現代瀏覽器請改用 position: fixed CSS 實現。
<?php
$link = mysql_pconnect("localhost", "xiaoyang", "xiaoyang") or die(mysql_error());
$link1 = mysql_select_db("database") or die(mysql_error());
?>
重要提醒:mysql_* 函式已於 PHP 7.0 移除,現代專案請改用 mysqli 或 PDO,並採用參數化查詢防範 SQL 注入。
<?php echo ""; ?>
疑為預留模板區塊,實際專案中通常包含導航列、使用者狀態等共用版頭內容。