I want to make text of title scrollable, I make the code as under it scrolls fine but the text I entered is displayed without space, meaning space in string is not considered.
<script type="text/javascript">
//function for tittle scrolling
function scrlsts() {
//var scrltest = " Nature ";
scrltest=document.title;
//alert(scrltest);
scrltest = scrltest.substring(1, scrltest.length) + scrltest.substring(0, 1);
//alert(scrltest);
document.title = scrltest;
setTimeout("scrlsts()", 1000);
}
$(document).ready(function() {
var scrltest = " Nature dff ssfd ";
document.title=scrltest;
scrlsts();
});
</script>
Thanks in advance
Haven't made these for a long time, but this should work:
(function titleScroller(text) {
document.title = text;
setTimeout(function () {
titleScroller(text.substr(1) + text.substr(0, 1));
}, 500);
}(" Nature dff ssfd "));
I made an easy and simple JavaScript library to accomplish this task.
<script type='text/javascript'>
title = "Your Title";
position = 0;
function scrolltitle() {
document.title = title.substring(position, title.length) + title.substring(0, position);
position++;
if (position > title.length) position = 0;
titleScroll = window.setTimeout(scrolltitle,170);
}
scrolltitle();
</script>
To stop the title scroll, just run:
window.clearTimeout(titleScroll);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With