|
|
|
| Доброго времени суток.
Нужен эффект к тексту, что-то типа пишущей машинки. Чтобы появлялся как "печатается".
Скрипт, который ниже не работает во всех браузерах. Подскажите, пожалуйста, как его можно доработать? Или может быть есть какой-то другой вариант?
****************************************************************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<script type="text/javascript" src="swfobject.js"></script>
<script language="javascript">
<!--
var delay=20;
var nextm=0;
var link=1;
zeilen=4; //hier angeben wieviele Zeilen du benutzt.
var msg=new Array
(
'text for example.'
);
function start_ticker()
{
do_ticker(msg[0], 0, 1);
}
function do_ticker(text, pos, dir)
{
var out='<font class="fuel_text">'+text.substring(0, pos)+'</font>';
if(navigator.appName=="Netscape")
with(document.ticker.document)
{
open(); write(out); close();
}
else
ticker.innerHTML=out;
pos+=dir;
if(pos>text.length)
setTimeout('do_ticker("'+text+'",'+pos+','+(-dir)+')', delay*100);
else
{
if(pos<0)
{
if(++nextm>=msg.length)
nextm=0;
link=link+1
if (link>=zeilen+1)
link=1;
text=msg[nextm];
dir=-dir;
}
setTimeout('do_ticker("'+text+'",'+pos+','+dir+')', delay);
}
}
function klick()
{
//hier die links.
if (link==1)
location.href="http://www.woweb.ru" //Dort Link 1 eintragen
}
// -->
</script>
</head>
<body onload="start_ticker()">
<div class="fuel_text" id="ticker"></div>
</body>
</html>
**************************************************************************** | |
|
|
|
|
|
|
|
для: Jaroslav
(24.10.2007 в 12:36)
| | или еще есть вот такой пример, но не работает в FireFox:
***********************************************************************
***********************************************************************
***********************************************************************
<head>
<title>Текст автоматически появляется побуквенно и заменяется</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<script>
// Set your messages. You may add as many messages as you like.
var message=new Array()
message[0]="WEB SPEED: test the speed of your browser and CPU."
message[1]="WEB ANIMATOR: create more than 20 text effects in minutes."
message[2]="WEB GUESTMAP: test more than 100 free guestmaps."
// Set font-family of the text
var fnt="Arial"
// Set font-size of the text (CSS-values)
var fntsize=14
// Set font-color of the text
var fntcolor="#CCCCCC"
// Set font-color of the last letter of the ticker
var fntcolorlastletter="#666666"
// Set font-weight. Set a value between 1 to 9 to adjust the boldness
var fntweight=7
// Set standstill between the messages (seconds)
var standstill=2
// Set speed (higher=slower)
var speed=80
// the top-position of the ticker (distance to the border on top, pixels)
var topposition=50
// the left-position of the ticker (distance to the border on the left, pixels)
var leftposition=20
// Do not edit the variables below
var tickerwidth
var tickerheight
var i_substring=0
var i_presubstring=0
var i_message=0
var messagecontent=""
var messagebackground=""
var messagepresubstring=""
var messageaftersubstring=""
fntweight=fntweight*100
standstill*=1000
var browserinfos=navigator.userAgent
var ie4=document.all&&!document.getElementById&&!browserinfos.match(/Opera/)
var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/)
var ns4=document.layers
var ns6=document.getElementById&&!document.all&&!browserinfos.match(/Opera/)
var opera=browserinfos.match(/Opera/)
var browserok=ie4||ie5||ns4||ns6||opera
for (i=0;i<=message.length-1;i++) {
message[i]=message[i]+" "
}
function initiateticker() {
if (ie4) {
tickerheight=document.body.clientHeight-5
tickerwidth=document.body.clientWidth-5
document.all.ticker.style.posLeft=leftposition
document.all.ticker.style.posTop=topposition
showticker()
}
if (ie5 || opera) {
tickerheight=document.body.clientHeight-5
tickerwidth=document.body.clientWidth-5
document.getElementById('ticker').style.left=leftposition
document.getElementById('ticker').style.top=topposition
showticker()
}
if (ns4) {
tickerheight=window.innerHeight-10
tickerwidth=window.innerWidth-10
document.ticker.left=leftposition
document.ticker.top=topposition
showticker()
}
if (ns6) {
tickerheight=window.innerHeight-10
tickerwidth=window.innerWidth-10
document.getElementById('ticker').style.left=leftposition
document.getElementById('ticker').style.top=topposition
getmessagecontentNS6()
}
}
function getmessagecontent() {
messagepresubstring=message[i_message].substring(0,i_presubstring)
messageaftersubstring=message[i_message].substring(i_presubstring,i_substring)
messagecontent="<table border=0 width="+tickerwidth+" height="+tickerheight+"><tr><td valign=top>"
messagecontent+="<span style='position:relative; font-family:"+fnt+";color:"+fntcolor+";font-size:"+fntsize+"pt;font-weight:"+fntweight+"'>"
messagecontent+="<font color='"+fntcolor+"'>"
messagecontent+=messagepresubstring
messagecontent+="</font>"
messagecontent+="</span>"
messagecontent+="<span style='position:relative; font-family:"+fnt+";color:"+fntcolor+";font-size:"+fntsize+"pt;font-weight:900'>"
messagecontent+="<font color='"+fntcolorlastletter+"'>"
messagecontent+=messageaftersubstring
messagecontent+="</font>"
messagecontent+="</span>"
messagecontent+="</td></tr></table>"
}
function getmessagecontentNS6() {
messagecontent="<table border=0 width="+tickerwidth+" height="+tickerheight+"><tr><td valign=top>"
messagecontent+="<span style='position:relative; font-family:"+fnt+";color:"+fntcolor+";font-size:"+fntsize+"pt;font-weight:"+fntweight+"'>"
messagecontent+="<font color='"+fntcolor+"'>"
messagecontent+=message[i_message]
messagecontent+="</font>"
messagecontent+="</span>"
messagecontent+="</td></tr></table>"
showtickerNS6()
}
function showticker() {
if (i_substring<=message[i_message].length-1) {
i_substring++
i_presubstring=i_substring-1
if (i_presubstring<0) {i_presubstring00}
getmessagecontent()
if (ie4) {
ticker.innerHTML=messagecontent
var timer=setTimeout("showticker()", speed)
}
if (ie5 || opera) {
document.getElementById('ticker').innerHTML=messagecontent
var timer=setTimeout("showticker()", speed)
}
if (ns4) {
document.ticker.document.write(messagecontent)
document.ticker.document.close()
var timer=setTimeout("showticker()", speed)
}
}
else {
clearTimeout(timer)
var timer=setTimeout("changemessage()", standstill)
}
}
function showtickerNS6() {
document.getElementById('ticker').innerHTML=messagecontent
i_message++
if (i_message>message.length-1) {i_message=0}
var timer=setTimeout("getmessagecontentNS6()", 2*standstill)
}
function changemessage() {
i_substring=0
i_presubstring=0
i_message++
if (i_message>message.length-1) {
i_message=0
}
showticker()
}
if (browserok) {window.onload=initiateticker}
</script>
<DIV ID="ticker" style="position:absolute"></DIV>
<DIV ID="do_not_delete_this" style="position:absolute"></div>
***********************************************************************
***********************************************************************
*********************************************************************** | |
|
|
|
|
|
|
|
для: Jaroslav
(24.10.2007 в 12:42)
| | Или может быть есть какой-то другой вариант?
======================================
Flash | |
|
|
|
|
|
|
|
для: elenaki
(24.10.2007 в 13:28)
| | а там как это сделать? | |
|
|
|
|
|
|
|
для: Jaroslav
(24.10.2007 в 13:39)
| | http://etcs.ru/blog/as2/ru/etcs/effects/texttween/ | |
|
|
|
|
|
|
|
для: Jaroslav
(24.10.2007 в 13:39)
| | Можно и без флешь обойтись, второй код работает, с чего вы взяли что он работает только в FF? А все переводить во флешь - это уже мания. | |
|
|
|
|
|
|
|
для: sim5
(24.10.2007 в 14:02)
| | нооборот. Не работает FF | |
|
|
|
|
|
|
|
для: Jaroslav
(24.10.2007 в 14:14)
| | Если долго не разбираться, то достаточно добавить:
var ff=document.getElementById&&!document.all&&!browserinfos.match(/Opera/)
var browserok=ie4||ie5||ns4||ns6||opera||ff
и везде, где раньше было if (ie5 || opera)
заменить на if (ie5 || opera || ff)
|
и будет работать в FF. | |
|
|
|
|
|
|
|
для: sim5
(24.10.2007 в 14:53)
| | ну почему-то не работает ( | |
|
|
|
|
|
|
|
для: Jaroslav
(24.10.2007 в 15:49)
| | Вы хоть правильно то в странцу его вставили? У вас ведь примеры и то неверно прописаны. | |
|
|
|
|
|
|
|
для: sim5
(24.10.2007 в 14:53)
| | Заработало!
Спасибо большое ) | |
|
|
|