标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
7 z4 \# y* m% T# f' ?6 }
var marqueewidth=300
% u/ {& w0 j5 b8 f( |1 d
//高度
' w' \, y N: m- E: Z% Z9 d7 @
var marqueeheight=25
9 B; H* o- Z9 n: T0 {
//速度(1-10)
x2 x+ Y; i. Z3 a
var marqueespeed=3
7 f4 k7 M; N: c) F2 ~$ y) i
//背景颜色
9 J' u, v0 ^0 W) d% [9 @: q) Z
var marqueebgcolor="#FFFFFF"
6 y& Z0 ~: g! H
//是否能暂停 (0=no. 1=yes)?
4 [8 m; A- V. y
var pauseit=1
5 }" G$ ~8 ]3 X
: {# P6 j. H, z& }+ p) j( `
//修改显示内容
1 i" p! @& L, H3 @
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
6 M) |8 Y$ X, A! @9 ~. L
* {: C* R- S# y7 n: }
; C8 @$ A0 S& |
////下面不需改变////////////
% |- N& H( I' Y/ D8 n! _8 F
0 T6 h9 _' z4 m' i& {& G
var copyspeed=marqueespeed
2 r: `9 F, G( O% E D2 F5 R6 C
var pausespeed=(pauseit==0)? copyspeed: 0
' b3 h3 C: O/ n+ p6 M4 \
var iedom=document.all||document.getElementById
/ l2 I6 e1 @7 H
if (iedom)
( d. z1 ?9 S8 l/ Q' B7 C
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
& C& a) w2 I! q" b% H' c; m: d2 S
var actualwidth=''
7 F# b2 |' k, |; J6 _. @8 L
var cross_marquee, ns_marquee
1 O, `9 M7 F. R& I3 Y& l; r! `
) U) k$ m# Y7 Q5 X
function populate(){
: B' R* O3 ?: H5 o- }/ O
if (iedom){
4 O1 S% ~1 z' M* ?0 V5 L8 t
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
+ p% e; l$ f" }1 e. ^
cross_marquee.style.left=marqueewidth+8
( u4 ^! ?5 m6 ^
cross_marquee.innerHTML=marqueecontent
" d2 c3 p. `8 O9 f1 g R1 U$ t9 e3 Y; Q
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
3 r+ s' Q9 G6 _' }- _# r
}
; O( N8 Q* L& B* P9 `! H
else if (document.layers){
* |& S% b4 \( E' @* T) e, n* _
ns_marquee=document.ns_marquee.document.ns_marquee2
# W& y0 A: [' f! X6 L
ns_marquee.left=marqueewidth+8
6 e. g' w' `% R5 Q+ P% j, @
ns_marquee.document.write(marqueecontent)
}! } a, K$ ?/ n
ns_marquee.document.close()
$ ?6 d$ a, `7 Z& d5 }
actualwidth=ns_marquee.document.width
' V4 S1 P9 H! R. ]
}
( p* _; j1 U( n# ^ O p
lefttime=setInterval("scrollmarquee()",20)
( }3 ?( e3 w; X: G$ q6 I
}
2 D) I" N6 \( E4 X J) ]
window.onload=populate
1 a. b# H9 ]$ H8 s- z. e+ G% h3 E7 W
+ y% B2 W( R1 F8 P
function scrollmarquee(){
$ o* ^6 F. C A" r+ _* ~/ Y
if (iedom){
. N& ` p4 u- a! D" C1 ^
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
3 o# K, n( R% K) Y
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
& H+ ~% ?9 h3 H# X7 o* r" ^
else
9 E$ X4 z! j2 M6 B; g8 K
cross_marquee.style.left=marqueewidth+8
0 ]1 Y: Y5 V9 o/ y* J: H
. R2 S" ^, w: J# x: B7 I+ |
}
* z! B$ W. n1 l2 Q2 y3 J* ^ n
else if (document.layers){
: {. i, N6 {2 a) }$ |- g
if (ns_marquee.left>(actualwidth*(-1)+8))
+ Z' t1 r$ V* w! {% P3 d6 [
ns_marquee.left-=copyspeed
: @, e1 Z) J+ n- y( A
else
1 L5 @' {' c5 N0 D- L) s( ]
ns_marquee.left=marqueewidth+8
( b& h7 `+ p2 Y' ?" h$ B4 e, r
}
5 r6 z: S' k7 w. Z6 V7 S N2 z
}
1 V! Y- y* h% _0 h
2 s* h! J" B, J8 X4 @9 ?* I) ^
if (iedom||document.layers){
- M( s) Z1 Z% a- K9 _
with (document){
" S U* {$ e, L9 i
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
5 t! Y1 a5 L9 m. s* Z0 @* t9 O1 r; d- c+ c
if (iedom){
6 Q( T" u# v1 q6 Q/ @ v1 A. u
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
( E1 W s5 |8 E
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
+ [- E# z+ v6 u% S& S7 Y
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
) X+ L9 @* f: u( N- O8 d7 X5 u
write('</div>')
7 M( Z4 e( W2 r# ^; w1 T3 `* R6 E! D
}
9 s, X0 i& u# j
else if (document.layers){
8 E7 i. G& g: a* Y( Q( _( v
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
* ^0 v! u0 n! V, Z) s) E
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
' C8 T Y5 C7 \
write('</ilayer>')
$ h- a" v2 l: Z8 S' E
}
! ?: {+ g3 F$ F1 a* Y [
document.write('</td></table>')
( x W* S, O$ }0 H9 P+ v- m4 y: A& l
}
6 B9 G3 a/ p$ `8 [" ]
}
& ~- s( s# _, s
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2