标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
9 a( ]2 c: `5 A# F3 Z- ]2 L2 i
var marqueewidth=300
! c( a, f- k6 v6 @ F
//高度
7 l( A: G+ _ g* C }) _
var marqueeheight=25
9 I( y" Y( r0 ]4 n
//速度(1-10)
/ B- u# }" r5 f+ _8 R( h0 I
var marqueespeed=3
* E% W5 ^: @+ Z
//背景颜色
- l( G# P' \6 b4 m
var marqueebgcolor="#FFFFFF"
; k, }- S- f4 |, q/ F
//是否能暂停 (0=no. 1=yes)?
* B0 P) E/ D f- n
var pauseit=1
. E9 m3 z( u: T1 Z! B' [7 ~2 u; `' ?
7 i: X: ?, b! m% S
//修改显示内容
' a4 L. Y G( D: O$ d- e: S
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
: I2 S# p; n h2 j, C
0 N4 Z% N% w0 U( \( k
2 Q* R% n( A$ C
////下面不需改变////////////
# Y w( M) [, a1 y& ^* K
9 E, C( K) k' f& m& x
var copyspeed=marqueespeed
6 m: |+ M/ G8 U" l7 V' c
var pausespeed=(pauseit==0)? copyspeed: 0
% m( v/ Q" F/ {9 T" i
var iedom=document.all||document.getElementById
# E$ m0 w' O0 L9 ^1 ]8 l7 r, f
if (iedom)
+ R% b1 }. q. @6 v( k. y
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
; t& f: `0 R! [9 i" }3 ~/ ?
var actualwidth=''
* i+ |! l; p; W7 z0 q% u+ t
var cross_marquee, ns_marquee
5 K- U2 p5 P7 J* W8 R! G1 G
# v7 c' G, Y3 R& x( ?4 e
function populate(){
1 P) l" }% a( i# `; v. s4 {
if (iedom){
# x- D0 c+ o$ P" H
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
2 H# Z A, y- b
cross_marquee.style.left=marqueewidth+8
q, ]% ]. K' A: V; Z% n- y1 s
cross_marquee.innerHTML=marqueecontent
' F( G/ I5 `; U$ e" p
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
) B' N; Y: n, [
}
1 t4 R6 f' ?% N* H5 ~) U
else if (document.layers){
- [$ r" F6 I/ Y0 G" m8 I% r
ns_marquee=document.ns_marquee.document.ns_marquee2
4 M( m9 d1 W2 C* k" @6 ]; i6 M
ns_marquee.left=marqueewidth+8
% m' K' G: U# H0 r4 Y( S. B
ns_marquee.document.write(marqueecontent)
* ?8 e' M5 ?5 E, w3 B1 C0 x2 n% c
ns_marquee.document.close()
0 D! i2 k. l& S( {8 V- Z: b
actualwidth=ns_marquee.document.width
/ C; y) B' o5 J2 p# a. E
}
& Z* h8 P* V8 E& u& }3 |0 x1 G
lefttime=setInterval("scrollmarquee()",20)
# a/ R( z% j/ W1 S
}
- ^6 R! k6 [% G1 h: N# B( x* u. l
window.onload=populate
! X B# z- _0 ]! S
) [0 x6 s+ s! p) q+ M
function scrollmarquee(){
$ `! {( k" O G4 v7 ~$ i% W- q2 @- d$ w3 K
if (iedom){
; S: F8 K0 }$ U8 s- D
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
* | u6 U, {" c+ c# f& [
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
% y. U v: y/ ^" U$ w
else
% X [0 v9 V' m
cross_marquee.style.left=marqueewidth+8
' I% q2 [: N* U
0 Q1 S5 O5 h* S; K# i, w
}
* b& T# d6 }# F0 s0 B' X
else if (document.layers){
( X) ^, g' p# N# U2 c- z; ?
if (ns_marquee.left>(actualwidth*(-1)+8))
* j) _# X' p7 ~* |( S* y
ns_marquee.left-=copyspeed
3 U: a$ I6 N6 Q4 Y; }& E
else
4 N$ @* y. K: C4 w& X/ B
ns_marquee.left=marqueewidth+8
2 h4 C9 P. Z" H: p4 Z) ~
}
( M% B2 I2 _9 D6 w7 K L3 w
}
/ s- ~! k% k5 g( q
' u- R( R. P7 L# K. z) i% p! {( h
if (iedom||document.layers){
' v) _. b8 M3 [; c H7 d, y
with (document){
1 Y# b( W% q9 x3 D& j
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
+ Q% i t9 ]+ q' m0 ?% D
if (iedom){
9 j9 `9 G( U0 S
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
T, S& C) K, H1 G/ Z& v
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
/ K# Q6 @8 }1 E
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
8 b# i# b6 V3 a( l, t
write('</div>')
9 ]8 F: [6 ]6 S0 F! w
}
% R; ^. N l0 T& L9 _
else if (document.layers){
: \0 K$ B& j1 J% h1 \
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
& D. t k* L# @8 K
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
8 z; P! ~2 l6 A$ ^) H
write('</ilayer>')
5 y! I% I, A, H, ]" a) C8 Q* I) m A: j+ ^
}
/ Q2 J; S0 t+ s! z% `0 I3 H( r
document.write('</td></table>')
7 i# ?) u x2 E7 g. ?, {7 k
}
! B) L& @$ V6 S: C
}
5 ^' z! F4 U' t9 W2 _# h
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2