Board logo

标题: 网页之跑马灯文字特效 [打印本页]

作者: zw2004    时间: 2008-1-21 20:53     标题: 网页之跑马灯文字特效

//修改宽度
" E- F  d/ F" N( u3 Pvar marqueewidth=300- k9 s; P4 B1 {8 B! ?; c, _
//高度0 n! I1 D$ q& ^7 B2 C
var marqueeheight=25% U, W- h* k0 E# g
//速度(1-10); }# P% H7 l8 ]6 `
var marqueespeed=3
. [+ V* p. A& w0 U//背景颜色+ K9 q& A7 y9 g% e1 ~* S3 t8 N
var marqueebgcolor="#FFFFFF"' z% d) x" h1 `
//是否能暂停 (0=no. 1=yes)?
1 w: Y" D* ~7 w2 Wvar pauseit=16 G4 e/ b7 k2 h" s/ I# x
1 w" n5 g0 r" \7 I7 c0 i) z
//修改显示内容
/ `7 J; T  d! G2 f( y: Lvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
6 w% N3 p0 ~% z+ r7 a: w) O! Q+ [6 P" w$ U) [; C, S' V
- y- h8 |& \" h$ [$ h* N
////下面不需改变////////////
7 w2 l4 y, R4 _. z0 a% F# i- M$ T7 ~3 Y
3 T2 |' \" t3 @9 o/ J8 Jvar copyspeed=marqueespeed
) D8 p, \, J: m2 M4 l* \var pausespeed=(pauseit==0)? copyspeed: 0
' _' S- x3 `& C# X/ H/ Q* ovar iedom=document.all||document.getElementById, r6 s* {4 u$ e. r
if (iedom)
6 }' c# i$ U, g5 O+ Udocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')) d+ C7 E" N+ ~9 u! s4 F( s, V
var actualwidth='') T7 R2 \. o& S7 }, T) t) z) {
var cross_marquee, ns_marquee( ~4 {" S4 p" G- _9 a+ M7 p

/ j" a0 R3 |6 Nfunction populate(){4 `9 E. K) J# r9 n- ?
if (iedom){/ S# M6 J% ?+ a! T; q9 J' ~, L
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee% r( b! P! y( f& [, n9 Z
cross_marquee.style.left=marqueewidth+8: d  t8 G' F0 A3 s0 N
cross_marquee.innerHTML=marqueecontent) |( q% b8 ^8 G* W
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth$ c# l5 s# A7 p( x( ^5 S& J, L$ {% N
}$ n. _% H  a2 \5 X" m
else if (document.layers){
) I7 I2 I/ o: w5 Sns_marquee=document.ns_marquee.document.ns_marquee2; D. u: X% g2 A7 t% i- m1 G' ^
ns_marquee.left=marqueewidth+84 t0 T7 P: c0 _" [
ns_marquee.document.write(marqueecontent)
7 f6 t3 {* U5 gns_marquee.document.close()
  r$ _: f& n0 g, u+ W* F3 G  {actualwidth=ns_marquee.document.width
4 n; P+ \; r6 W- E" W8 a% k0 W}" c6 l$ S: ^2 a3 U0 [# f
lefttime=setInterval("scrollmarquee()",20)- Q0 k; K4 R- I9 q
}7 @: @+ f- _$ o, @7 y' z
window.onload=populate
/ `- N/ \6 R: T% k7 v
' ?+ a7 F7 E8 {0 f" A: f) _( yfunction scrollmarquee(){
0 l/ \3 X+ f) ]! Wif (iedom){
; w9 u. z, K( E- e, X" J- Pif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
1 w/ c! _# L4 bcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
. m8 r+ I9 q8 g7 pelse" N" a3 Z# `! y% M
cross_marquee.style.left=marqueewidth+8
3 X8 M6 u* B  g/ W+ m
9 {! ?2 t3 R' N3 t- F/ I5 G7 E}
* _# `' z' L% R3 i5 Belse if (document.layers){6 h+ n- `3 c2 x; A
if (ns_marquee.left>(actualwidth*(-1)+8))% u0 O( d9 Y6 Z) B
ns_marquee.left-=copyspeed
% O5 W* f8 _; v6 Lelse4 m, H- i& D+ F1 P! I( z5 O7 ?
ns_marquee.left=marqueewidth+8
; O- T, J' Z' J! `4 p}
5 x( v2 ?+ e8 K: C, v% y}1 z! i# @% @" ?) Q

% m" h  s2 i( D, T" L- Kif (iedom||document.layers){
8 a$ X) T0 u2 V) O3 ewith (document){
" q/ {, I5 P4 s# |5 Sdocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')- t; S( r& @# T& C0 ?
if (iedom){
1 l* C! g) i( U7 ]* fwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')# D# g  K; ^4 D0 g1 T
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')1 [( e) f7 W, z7 v3 F4 U/ C( j* L
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')( e5 x+ M* C2 Z, E
write('</div>')4 h& B/ r1 E, {5 V6 U
}
% b" ]. V3 z' g4 celse if (document.layers){
' e# L# c/ w# U7 L3 j8 bwrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
! \* P+ u) W# t" \# @write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
: J4 ^+ ?8 R  \. ]* P9 y" cwrite('</ilayer>')* F/ Y; ^( ^$ P; b8 Z
}+ U" U" L$ f' P' o. b9 S
document.write('</td></table>')0 W9 ^$ \8 Q) ]
}
& g- e; Q" D1 v  R- D6 E6 P}7 L& l8 N5 J, A3 O
</script>




欢迎光临 捌玖网络工作室 (http://89w.org/) Powered by Discuz! 7.2