Use JavaScript to make the title of a page work _ Text effects

Source: Internet
Author: User
Tags setinterval
HTML Title:
Copy Code code as follows:
<title> Hello, MR-S.R lee</title>

Javascript:
Copy Code code as follows:

<script type= "Text/javascript" >
function Scroll () {
Gets the title information.
var titleinfo = Document.title;
Gets the first Chinese character (number, letter) of title.
Note: The subscript for the first character in the string is 0. If the argument index is not between 0 and String.Length, the method returns an empty string.
var firstinfo = Titleinfo.charat (0);
Gets the second to the last message.
var lastinfo = titleinfo.substring (1, titleinfo.length);
Splicing Output Information
Document.title = Lastinfo + firstinfo;
}
Use the SetInterval () method to perform
SetInterval ("Scroll ()", 500);
</script>

Full Demo Code:
<title> Hello, mr-s.r lee</title> <script type= "text/ JavaScript "> function scroll () {//Get title information. var titleinfo = Document.title; Gets the first Chinese character (number, letter) of title. Note: The subscript for the first character in the string is 0. If the argument index is not between 0 and String.Length, the method returns an empty string. var firstinfo = Titleinfo.charat (0); Gets the second to the last message. var lastinfo = titleinfo.substring (1, titleinfo.length); Stitching output Information Document.title = Lastinfo + firstinfo; ///Use SetInterval () method to execute SetInterval ("scroll ()", 500); </script>
[ctrl+a All selected note: If you need to introduce external JS need to refresh to perform]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.