function Marquee()
專注于為中小企業(yè)提供成都網(wǎng)站設(shè)計、網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)延安免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了1000+企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
{ if(demo2.offsetWidth-demo.scrollLeft=0)
demo.scrollLeft-=demo1.offsetWidth
else{ demo.scrollLeft++ }
}
上面這段代碼控制橫向滾動條滾動
var MyMar=setInterval(Marquee,speed)
上面這段代碼讓瀏覽器每30毫秒調(diào)用一次Marquee函數(shù)
也就是讓滾動條滾動
demo.onmouseover=function()
{
clearInterval(MyMar)
}
上面這段代碼讓 當(dāng)鼠標(biāo)移動到demo控件上時停止調(diào)用Marquee函數(shù)
也就是說,鼠標(biāo)移動到demo控件上,滾動條不再滾動
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
上面這段代碼 當(dāng)鼠標(biāo)從demo控件上移開始,繼續(xù)每30毫秒調(diào)用一次Marquee函數(shù)
也就是讓滾動條繼續(xù)滾動
把下面這段代碼加到BODY ........后面
DIV id=ly2
style="HEIGHT: 128px; LEFT: 0px; POSITION: absolute; TOP: 0px; WIDTH: 150px"A
href="prodlist.php?departmentid=3" target=_blankIMG
src="images/hadef.gif" border=0/A/DIV
SCRIPT
PI=3.1416;
if (window.screen.width==1024)
{
center_x=400;
center_y=300;
}
if (window.screen.width==800)
{
center_x=300;
center_y=200;
}
function _locate_layer(this_layer,cx,cy,x,y)
{
this_layer.style.top=document.body.scrollTop+cy-y;
this_layer.style.left=document.body.scrollLeft+cx+x;
}
// ly2:move sin-----------------------------------------------------
_move_sin_ly2_run=1;
_move_sin_ly2_i=0;
function _move_sin_ly2(x_step,y_step)
{
x=_move_sin_ly2_i;
y=Math.sin(x/50)*y_step;
_move_sin_ly2_i=_move_sin_ly2_i+x_step;
_locate_layer(ly2,0,center_y,x,y);
if (x(window.screen.width-250)) _move_sin_ly2_i=0;
}
function _move_sin_ly2_pro()
{
_move_sin_ly2(2,75);
if (_move_sin_ly2_run) setTimeout("_move_sin_ly2_pro()",100);
}
function _move_sin_ly2_pro_pause()
{
_move_sin_ly2_run=0;
}
function _move_sin_ly2_pro_play()
{
_move_sin_ly2_run=1;
_move_sin_ly2_pro();
}
// ly2:move sin------------------------------------------------------
_move_sin_ly2_pro();
/SCRIPT
樓主咋能這樣說捏…………這是個很簡答的東西…………
自己看最后一個javascript函數(shù)的注釋,頁面上的展示是一個DNA式的展示,其實就是兩個樓主要求的東西向不同方向開始震動…………
很郁悶,20分鐘完成功能,花了一個小時來優(yōu)化了下代碼…………
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
html
head
title旗幟飄揚(yáng).html/title
meta http-equiv="keywords" content="keyword1,keyword2,keyword3"
meta http-equiv="description" content="this is my page"
meta http-equiv="content-type" content="text/html; charset=UTF-8"
!--link rel="stylesheet" type="text/css" href="./styles.css"--
style type="text/css"
.flaggingStyle {
color: #0066ff;
font-family: 隸書;
font-size: 24pt;
font-weight: normal;
}
/style
script type="text/javascript"
function flaggingMove(strTargetName, flaggingPosNo, flaggingVolatility, messageLength) {
for (var i = messageLength - 1; i = 1; i--) {
document.getElementById("Flag_" + strTargetName + i).style.top = document.getElementById("Flag_" + strTargetName + (i - 1)).offsetTop;
}
var target = document.getElementById(strTargetName);
var nowPos = parseInt(target.getAttribute("flaggingPosition"));
var nowDir = parseInt(target.getAttribute("flaggingDrection"));
if (nowPos == flaggingPosNo || nowPos == flaggingPosNo * -1) {
nowDir = nowDir * -1;
target.setAttribute("flaggingDrection", nowDir);
}
nowPos = nowPos + nowDir;
target.setAttribute("flaggingPosition", nowPos);
document.getElementById("Flag_" + strTargetName + "0").style.top = target.offsetTop + flaggingVolatility * Math.sin(Math.PI * nowPos / 2 / flaggingPosNo);
}
function flaggingReColor(strTargetName, messageLength) {
for (var i = messageLength - 1; i = 1; i--) {
document.getElementById("Flag_" + strTargetName + i).style.color = document.getElementById("Flag_" + strTargetName + (i - 1)).style.color;
}
document.getElementById("Flag_" + strTargetName + "0").style.color = Math.random() * 255 * 255 * 255 + Math.random() * 255 * 255 + Math.random() * 255;
}
function startFlagging(strCtrlName, flaggingPosNo, flaggingVolatility, messageLength, flaggingTerm, reColorTerm){
window.setInterval("flaggingMove('" + strCtrlName + "', " + flaggingPosNo + ", " + flaggingVolatility + ", " + messageLength + ");", flaggingTerm);
window.setInterval("flaggingReColor('" + strCtrlName + "', " + messageLength + ");", reColorTerm);
}
/**
* strFlaggingMessage 字符串,信息內(nèi)容
* textwidth 數(shù)字,信息字符的寬度
* flaggingPosNo 數(shù)字,半周期變化位置的次數(shù)
* startPos 數(shù)字,小于等于flaggingPosNo,開始位置
* startDir 數(shù)字,1或-1,開始時字符移動的方向(向上或向下)
* flaggingVolatility 數(shù)字,字符每次移動的距離,flaggingVolatility*flaggingPosNo*2=字符震動的幅度
* flaggingTerm 數(shù)字,字符每隔多少毫秒移動一次,flaggingTerm*flaggingPosNo*4=字符震動的周期
* reColorTerm 數(shù)字,字符顏色每隔多少毫秒變化一次
* flaggingClass 字符串,定義字符的css的classname
*/
function flaggingCtrl(strFlaggingMessage, textwidth, flaggingPosNo, startPos, startDir, flaggingVolatility, flaggingTerm, reColorTerm, flaggingClass) {
var strCtrlName = "FlaggingMessageCtl";
if(document.getElementById(strCtrlName)){
var i = 0;
while(document.getElementById(strCtrlName + "_" + i)){
i = i + 1;
}
strCtrlName = strCtrlName + "_" + i;
}
document.write("span id=\"" + strCtrlName + "\"/span");
var target = document.getElementById(strCtrlName);
var x = target.offsetLeft;
var y = target.offsetTop;
target.style.position = "absolute";
target.setAttribute("flaggingPosition", startPos);
target.setAttribute("flaggingDrection", startDir);
var messageArr = strFlaggingMessage.split("");
for (i = 0; i = messageArr.length - 1; i++) {
var newSpan = document.createElement("span");
newSpan.innerText = messageArr[i];
newSpan.setAttribute("id", "Flag_" + strCtrlName + i);
newSpan.className = flaggingClass;
newSpan.style.position = "absolute";
newSpan.style.top = y;
newSpan.style.left = x + i * textwidth;
document.body.appendChild(newSpan);
}
startFlagging(strCtrlName, flaggingPosNo, flaggingVolatility, messageArr.length, flaggingTerm, reColorTerm);
}
/script
/head
body
br /
br /
br /
br /
br /
br /
br /
br /
br /
script type="text/javascript"
flaggingCtrl("準(zhǔn)備要像旗幟飄揚(yáng)般晃動的信息1………………", 35, 4, 0, -1, 50, 35, 300, "flaggingStyle");
/script
script type="text/javascript"
flaggingCtrl("準(zhǔn)備要像旗幟飄揚(yáng)般晃動的信息2………………", 35, 4, 0, 1, 50, 35, 300, "flaggingStyle");
/script
/body
/html
DIV id=img style="position:absolute;z-index=99;" A href="#" target=_blankIMG height=80 width=80 alt="dfs" src="#" border=0 /A/DIV SCRIPT language=javascript !-- Begin var xPos = 20; var yPos = document.body.clientHeight; var step = 1; var delay = 30; var height = 0; var Hoffset = 0; var Woffset = 0; var yon = 0; var xon = 0; var pause = true; var interval; img.style.top = yPos; function changePos() { width = document.body.clientWidth; height = document.body.clientHeight; Hoffset = img.offsetHeight; Woffset = img.offsetWidth; img.style.left = xPos + document.body.scrollLeft; img.style.top = yPos + document.body.scrollTop; if (yon) { yPos = yPos + step; } else { yPos = yPos - step; } if (yPos 0) { yon = 1; yPos = 0; } if (yPos = (height - Hoffset)) { yon = 0; yPos = (height - Hoffset); } if (xon) { xPos = xPos + step; } else { xPos = xPos - step; } if (xPos 0) { xon = 1; xPos = 0; } if (xPos = (width - Woffset)) { xon = 0; xPos = (width - Woffset); } } function start() { img.visibility = "visible"; interval = setInterval('changePos()', delay); } start(); // End -- /SCRIPT 把代碼復(fù)制到你的網(wǎng)頁中
應(yīng)該是Flash,但是做的東西是Microangelo,Microangelo是一款小而強(qiáng)大的圖標(biāo)制做器,安裝完成后才5MB哦!!!中文版的簡單極了!!!
懸浮窗或者浮動窗。
浮動窗有兩種方式,一種是浮動的層在網(wǎng)頁上面任意飄動,一種是浮動的層跟隨滾動條來回移動。這兩種效果一般都可以利用javascript制作出來的。
網(wǎng)頁上飄動的動態(tài)網(wǎng)頁指網(wǎng)頁是根據(jù)用戶請求,由服務(wù)器上程序動態(tài)的生成的浮動窗。