找到一個有類似效果的java script,但只能出現一個方塊。
語法如下:
先在網頁的<head>和</head>之間插入這段文字:
HTML 代碼:
<style>
<!--
/*Post-it note script- by javascriptkit.com
Visit JavaScript Kit ([url]http://javascriptkit.com[/url]) for script
Credit must stay intact for use*/
#postit{
position:absolute;
width:250;
padding:5px;
background-color:lightgreen;
border:1px solid red;
visibility:hidden;
z-index:100;
cursor:hand;
}
-->
</style>
然後在網頁內容的<body>和</body>之間,最好是靠近底部以後比較好參考,放入這段文字:
HTML 代碼:
<div id="postit" style="left:150px;top:150px">
<div align="right"><b><a href="javascript:closeit()">[關閉]</a></b></div>
<!--INSERT YOUR CONTENT HERE-->
<b>便利貼:</b><br>
<p><font size="2" face="Arial"><a href="http://www.webmasterclub.org" target="_new">站長俱樂部<br>
</a>歡迎參加站長俱樂部論壇</font></p>
<p><font size="2" face="Arial"><a href="http://www.domainclub.org" target="_new">網域名稱俱樂部<br>
</a>網域名稱買賣、交易、評估等討論。</font></p>
<!--END YOUR CONTENT HERE-->
</div>
<script>
//Post-it only once per browser session? (0=no, 1=yes)
//Specifying 0 will cause postit to display every time page is loaded
var once_per_browser=0
///No need to edit beyond here///
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all
if (ns4)
crossobj=document.layers.postit
else if (ie4||ns6)
crossobj=ns6? document.getElementById("postit") : document.all.postit
function closeit(){
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
crossobj.visibility="hide"
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function showornot(){
if (get_cookie('postdisplay')==''){
showit()
document.cookie="postdisplay=yes"
}
}
function showit(){
if (ie4||ns6)
crossobj.style.visibility="visible"
else if (ns4)
crossobj.visibility="show"
}
if (once_per_browser)
showornot()
else
showit()
</script>
<script language="JavaScript1.2">
//drag drop function for ie4+ and NS6////
/////////////////////////////////
function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx
crossobj.style.top=tempy+e.clientY-offsety
return false
}
}
function initializedrag(e){
if (ie4&&event.srcElement.id=="postit"||ns6&&e.target.id=="postit"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY
tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)
dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")
</script>