- 1、淘寶里首頁飄雪花 怎麼弄啊 js代碼放在哪裡啊 本人小白 希望大神詳解…..
- 2、利用JS給網頁添加雪花飄落的效果
- 3、怎麼讓網頁上飄着雪花
div class=”J_TWidget” data-widget-config=”{‘duration’:0.1,’activeTriggerCls’:’.tshop-psm-shop-ww-hover’,’interval’:0.1,’effect’:’scrollx’,’activeIndex’:1,’navCls’:’user-crzysj’,’contentCls’:’user-crzysjii’,’autoplay’:true}” data-widget-type=”Carousel” style=”position:relative;”ul class=”user-crzysjii” style=”display: none; width: 999999px; left: 0px; position: absolute;”li class=”-_-switchable-panel-internal535 ks-switchable-panel-internal998″ style=”width: 475px; height: 800px; display: block; float: left;” /li/ulul class=”user-crzysj”li class=”-_-switchable-trigger-internal534 ks-switchable-trigger-internal997 tshop-psm-shop-ww-hover” style=”width:475px;height:800px;right:50%;margin-right:505px;”embed allownetworking=”all” allowscriptaccess=”never” flashvars=”scene=taobao_shop” height=”1000″ name=”flashfirebug_1387778983714″ src=”” type=”application/x-shockwave-flash” width=”475″ wmode=”transparent”/li/ul/divdiv class=”J_TWidget” data-widget-config=”{‘duration’:0.1,’activeTriggerCls’:’.tshop-psm-shop-ww-hover’,’interval’:0.1,’effect’:’scrollx’,’activeIndex’:1,’navCls’:’user-crzysj’,’contentCls’:’user-crzysjii’,’autoplay’:true}” data-widget-type=”Carousel” style=”position:relative;z-index:99;”ul class=”user-crzysjii” style=”display: none; width: 999999px; left: 0px; position: absolute;”li class=”-_-switchable-panel-internal635 ks-switchable-panel-internal1108″ style=”width: 475px; height: 800px; display: block; float: left;” /li/ulul class=”user-crzysj”li class=”-_-switchable-trigger-internal634 ks-switchable-trigger-internal1107 tshop-psm-shop-ww-hover” style=”width:475px;height:800px;left:50%;margin-left:505px;”embed allownetworking=”all” allowscriptaccess=”never” flashvars=”scene=taobao_shop” height=”1000″ name=”flashfirebug_1387778983652″ src=”” type=”application/x-shockwave-flash” width=”475″ wmode=”transparent”/li/ul/div
直接在首頁添加個自定義模塊 編輯 點兩個箭頭的那個編輯代碼模式 然後複製代碼放進去 確定就好!
1、修改部分如下:
html
head
script src=” Demo/jsized.snow.min.js” type=”text/javascript”/script
script
/**
* This function takes 2 arguments
* First is the path to the directory with snowflake images
* Second is the maximum number of snowflakes, please do not
* set this number above 60 as it will impact the performance
*/
createSnow(“”, 60);//目錄改為當前目錄
/script
/head
body
測試
/body
/html
2、在該網頁目錄 下 新添加 四張雪花圖片 命名規則(snow0.gif snow1.gif snow2.gif snow3.gif)
在後台添加js特效可實現這樣的效果。
js代碼為:
script language=”JavaScript”
!–
var no = 5; //雪片數目
var speed = 20; //飄動速度。(值越大越慢)
var ns4up = (document.layers) ? 1 : 0; //當前瀏覽器類型,如果是NS則為1
var ie4up = (document.all) ? 1 : 0; //當前瀏覽器類型,如果是IE則為1
var s, x, y, sn, cs;
var a, r, cx, cy;
var i, doc_width = 800, doc_height = 600;
x = new Array();
y = new Array();
r = new Array();
cx = new Array();
cy = new Array();
s = 8; //每次下落的高度,越小越平滑,但是也越慢
if (ns4up) { //以NS兼容方式
doc_width = self.innerWidth; //取頁面寬度
doc_height = self.innerHeight; //取頁面高度
}
else
if (ie4up) { //以IE兼容方式
doc_width = document.body.clientWidth; //取頁面寬度
doc_height = document.body.clientHeight; //取頁面高度
}
for (i = 0; i no; ++ i) { //根據前面定義的雪片數目寫進相應數目的層
initSnow(); //隨機初始化層的坐標
if (ns4up) { //如果瀏覽器是NS
//用layer作為雪片(星號)的容器
document.write(“layer name=\”dot”+ i +”\” left=\”1\” “);
document.write(“top=\”1\” visibility=\”show\”font color=\”red\””);
document.write(“*/font/layer”);
}
else
if (ie4up) { //如果瀏覽器是IE
//用div作為雪片的容器
document.write(“div id=\”dot”+ i +”\” style=\”POSITION: “);
document.write(“absolute; Z-INDEX: “+ i +”; VISIBILITY: “);
document.write(“visible; TOP: 15px; LEFT: 15px;\”font color=\”red\””);
document.write(“*/font/div”);
}
}
//初始化雪片,生成隨機坐標
function initSnow() {
a = 6;
r[i] = 1;
sn = Math.sin(a);
cs = Math.cos(a);
cx[i] = Math.random() * doc_width + 1;
cy[i] = Math.random() * doc_height + 1;
x[i] = r[i] * sn + cx[i];
y[i] = cy[i];
}
//計算雪花位置,從新位置上出現,看起來就像是新產生的一樣。
function makeSnow() {
r[i] = 1;
cx[i] = Math.random() * doc_width + 1;
cy[i] = 1;
x[i] = r[i] * sn + cx[i];
y[i] = r[i] * cs + cy[i];
}
//雪花下落的計算
function updateSnow() {
r[i] += s;
x[i] = r[i] * sn + cx[i];
y[i] = r[i] * cs + cy[i];
}
//在NS瀏覽器上處理雪片下落的主程序
function SnowdropNS() {
for (i = 0; i no; ++ i) { //依次處理每片雪花
updateSnow(); //下落
if ((x[i] = 1) || (x[i] = (doc_width – 20)) || (y[i] = (doc_height – 20))) { //如果超出屏幕範圍
makeSnow(); //則調整雪片到新位置上
doc_width = self.innerWidth; //更新頁面寬度數據
doc_height = self.innerHeight; //更新頁面高度數據
}
document.layers[“dot”+i].top = y[i]; //改變層的Y坐標,應用新的位置
document.layers[“dot”+i].left = x[i]; //改變層的X坐標,應用新的位置
}
setTimeout(“SnowdropNS()”, speed);
}
//在IE瀏覽器上處理雪片下落的主程序
function SnowdropIE() {
for (i = 0; i no; ++ i) { //依次處理每片雪花
updateSnow(); //下落
if ((x[i] = 1) || (x[i] = (doc_width – 20)) || (y[i] = (doc_height – 20))) { //如果超出屏幕範圍
makeSnow(); //則調整雪片到新位置上
doc_width = document.body.clientWidth; //更新頁面寬度數據
doc_height = document.body.clientHeight; //更新頁面高度數據
}
document.all[“dot”+i].style.pixelTop = y[i]; //改變層的坐標,應用新的位置
document.all[“dot”+i].style.pixelLeft = x[i];
}
setTimeout(“SnowdropIE()”, speed); //準備下一次下落過程。
}
if (ns4up) { //如果是NS
SnowdropNS(); //調用SnowdropNS使雪片下落
}
else
if (ie4up) { //如果是NS
SnowdropIE(); //調用SnowdropIE使雪片下落
}
—
/script
說明:可以根據自己的需求根據說明進行相應參數的修改
原創文章,作者:EOGDK,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/126301.html