Как вернуть анимированному <title> прежнее значение?
Всем привет!
Имею код: <html><head><title>Бегущая строка.</title> <script>(function titleMarquee(){document.title=document.title.substring(1)+document.title.substring(0,1); orgn_ttl=setTimeout(titleMarquee,600);})();</script></head> <body> <button title="Stop The Title" onclick="clearTimeout(orgn_ttl);"> Stop Title</button> </body></html> Необходимо остановить анимированный <title> и вернуть первоначальную позицию. Т.е. кнопка <button> его останавливает, но не возращает первоначальное положение- текст просто замирает посередине. Хотелось-бы что-бы анимация не только останавливалась но и <title> принимал исходное положение. |
tuchkovo-auto,
<script>var defaultTitle=document.title;(function titleMarquee(){document.title=document.title.substring(1)+document.title.substring(0,1);orgn_ttl=setTimeout(titleMarquee,600);})();</script> <button title="Stop The Title" onclick="clearTimeout(orgn_ttl);document.title=defaultTitle;">Stop Title</button> |
tuchkovo-auto,
:cray: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Бегущая строка.</title> <script> var title = document.title, orgn_ttl; function titleMarquee(a) { a ? (clearTimeout(orgn_ttl), document.title = title) : (document.title = document.title.substring(1) + document.title.substring(0, 1), orgn_ttl = setTimeout(titleMarquee, 600)) } titleMarquee(); </script> </head> <body> <button title="Stop The Title" onclick="titleMarquee(true)">Stop Title</button> </body> </html> |
<!Doctype html> <html> <head> <meta charset="utf-8"> <title>Бегущая строка::</title> </head> <body> <form name="form_1"> <input type="button" name="button_1" value="Stop Title"> <input type="button" name="button_2" value="Star Title"> </form> </body> <script> ot = document.title; document.form_1.button_1.onclick = function() { clearTimeout(orgn_ttl); document.title = ot; } title = document.form_1.button_2.onclick = function() { var s = document.title; document.title = s.substr(1) + s.substr(0,1); orgn_ttl = setTimeout ( title, 132 ) ; }; title(); </script> </html> |
:)
|
Ребята всем Спасибо! У всех скрипты работают, но выберу пожалуй скрипт от MallSerg, этот скрипт и на странице, и в выносном скрипте с jQuery работает!
|
Часовой пояс GMT +3, время: 12:13. |