Tag's Custom class

Source: Internet
Author: User
Tags add array object net return tostring window

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "><ptml xmlns=" http://www.w3.org/1999/xhtml ><pead> <title> Untitled page </title> <link href= " Http://www.17mm.net/StyleSheet.css "rel=" StyleSheet "type=" Text/css "/> <script language=" javascript "type=" Text/javascript "src=" http://www.17mm.net/TagPage.js "></script> <script language=" javascript "type=" Text/javascript "> Function Crea () {var obj = new Ctagpages (" Maintag "); Obj.add (New Ctpage ("Files", "File 1", "content6");//Create a content page that does not exist in a document Obj.add (new Ctpage ("edits", "edit", "Content2")); Obj.add (New Ctpage ("Windows", "Window", "Content3")); Obj.add (New Ctpage ("helps", "help", "content4")); Document.all.tag.innerHTML = obj; Obj.settag (1); } window.onload = Crea; </script></pead><body> <pr/>;d IV id= "tag" ></div> <!--<div id= "content1" class= "Content" style= "Background-color:green;" > I love you china </div>--> <div id= "Content2" class= "Content" style= "Background-color:aqua;" > Love you china </div> <div id= "Content3" class= "Content" style= "Background-color:fuchsia" > China Love You </div> ;d IV id= "CONTENT4" class= "Content" style= "Background-color:blue" > I love you. China </div> <div id= "Tag1" ></div ></body></ptml>

[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

Ctagpages
Property
Tagpages Tag Array

Method

[N] Retrieving labels
Add Add Tag Page
Delete Label page
Update tab page
Insert tab page
Clear clears the tab page
Settag set a label is selected, the parameter can be tag ID can also be a serial number
Gettag Gets the selected tag object

Ctpage
Property
TagID Label ID
Text displayed on the Tagcaption label
Tagcontid Label Content ID

js class Download

How to use
1.var tagpages = new Ctagpages ("Maintag"); Create a Tagpages object, the parameter is the ID of this tag page collection, distinguish the other label page
2.var tagpage = new Ctpage ("Files", "File", "Content6"); Set up a tab page, parameter 1 refers to the ID of this tab page, parameter 2 label text,
Parameter 3 The DIV relative to this label, if you specify a div that does not exist in the document, the system automatically creates a div;
3.tagpages.add (tagpage); Use the Add method to add the label to the label page.
4.document.all.tag.innerhtml = tagpages; Add the tab page to the document.
5.tagpages.settag (1) or Tagpages.settag ("files"), set the default selected tab, parameters can use [number] and [ID name] two ways
//

Public variables
var currenttag = null;
var currentdiv = null;

//////////////////////////////////////////////////////////////////
////////////////////////////////
// Single Label object
function Ctpage (TagID, tagcaption, tagdiv) {
    this.checkdiv (tagdiv);
    this.id = TagID;
    this.caption = tagcaption;
    this.divid = tagdiv;
    this.selected = false;
}

Function tagtostring () {
    var str = "<li class=\";
        str + + this.selected? " Focus ":" "blur";
        str + = "\ id=\" "+ this.id +" \ "+
     & nbsp;        "divid=\" "+ This.divid +" \ "+
               "Onclick=\" Secboard (this) \ "" +
               ">" + this.caption + "</li>";
    return str;
}

function Checkdiv (divname) {
var tdiv = document.getElementById (divname);
if (!tdiv) {
Tdiv = document.createelement ("DIV");
Tdiv.id = Divname;
Tdiv.classname = "Content";
tdiv.innerhtml = "new";
Document.body.appendChild (TDIV);
}
Tdiv.style.display = "None";
}
CTPage.prototype.checkDiv = Checkdiv;
CTPage.prototype.toString = tagtostring;
////////////////////////////////////////////////////////////////
//////////////////////////////
Tag Collection Object

function Ctagpages (ID) {
This.id = ID;
This.tagpages = new Array ();
}

function Add (OBJTG) {
This.tagpages[this.tagpages.length] = OBJTG;
}

function pagetostring () {
var str= "<ul id=\" "+this.id+" \ "class=\" tagpage\ ">";
for (var i=0; i<this.tagpages.length; i++) {
str = this.tagpages[i];
}
STR + + "</ul>";

return str;
}

function Index (n) {
if (n>this.tagpages.length-1 | | n<0) {
Return
}else{
return this.tagpages[n];
}
}

function Settag (n) {
var curtag = null;
if (typeof (n) = = "string") {
Curtag = document.getElementById (n);
}else{
var Curtag = document.getElementById (this.id). Childnodes[n];
}
if (Curtag) {
if (Currenttag && currentdiv) {
Currenttag.classname = "blur";
CurrentDiv.style.display = "None";
}
Curtag.classname = "Focus";
Currenttag = Curtag;
var curdiv = document.getElementById (Curtag.divid);
CurDiv.style.display = "block";
Currentdiv = Curdiv;
}
}

CTagPages.prototype.setTag = Settag;
CTagPages.prototype.index = index;
CTagPages.prototype.add = add;
CTagPages.prototype.toString = pagetostring;

////////////////////////////////////////////////////////////////
/////////////////////////////////
Common functions

function Secboard (obj)
{
var obj = event.srcelement;
Currenttag.classname = "blur";
Currenttag = obj;
Currenttag.classname = "Focus";

CurrentDiv.style.display = "None";
Currentdiv = document.getElementById (Obj.divid);
CurrentDiv.style.display = "block";
}



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.