search
HomeWeb Front-endCSS TutorialHTML COMPONENTS Part 5

HTML COMPONENTS Part 5

Dec 17, 2016 pm 01:52 PM

 The ANYDAY component is defined in day, htc. This component is a package of the calendar unit. The name of the component is determined by the xml namespace defined on the first line.



 Just like canlenar.htc, you only have one namespace definition. The reason is that there is no need to call other HTCs on this page. That is to say, the HCT is a leaf HTC. The custom label we define here is DAY. We also define Its behavior, in fact, the definition of the HTML component is the definition of the custom tag behavior, which includes an attribute and an event:

<PUBLIC:COMPONENT tagName="DAY"> 
<PROPERTY NAME="value"></PROPERTY> 
<ATTACH EVENT="oncontentready" ONEVENT="fnInit()"<>/ATTACH> 
</PUBLIC:COMPONENT>

Pay attention to the event oncontentready , when its caller calendar.htc asks to import day.htc and is fully imported, this event will be generated. The handler of the event is fnInit(). Let’s take a look at it:

function fnInit() { 
document.body.innerHTML = element.value; 
document.body.className = "clsDay"; 
defaults.viewLink = document; 
element.appointments = ""; 
element.date = element.value; 
}

 fnInit() demonstrates many important HTC chapter. The first line assigns element.value to the innerHTML of the calling page Attributes. HTML components are always encapsulated in element objects. The value attribute is generally defined in the PROPERTY tag. As a reminder, the actual value is passed in from the calling page, canlendar.htc:
text += '

'
The cell style is specified on the second line:

document.body.className = "clsDay";
The style class clsDay is defined elsewhere on the page:

<STYLE> 
.clsDay { 
width:50; 
height:50; 
background-color:lightyellow; 
align:center; 
text-align:right; 
} 
</STYLE>


Notice that the dates in the calendar are colored bright yellow, which proves that HTC’s format-specific mode is dominated by its caller, namely: calendar.htc.
 The third line of fninit() sets the viewlink attribute of the default object. The viewLink attribute is the basis of the HTML component. It can make an HTC document (day.htc) visible to another HTML component (calendar.htc). Here it is viewLink settings:

defaults.viewLink = document;

 Note that what you need to connect is the entire document object. The last two lines of fnInit() initialize two internal properties that we will explain later:

element.appointments = "";
element.date = element.value;

is used for its own display, DAY HTML component is related to mouse click:



When the day is clicked, the user is reminded to add his or her appointment on that day, or modify an existing appointment:
function fnShowAppts() { 
newAppointments = prompt("Add your 
appointment:", element.appointments); 
if (newAppointments != null) 
element.appointments = newAppointments; 
document.body.innerHTML = &#39;<FONT 
COLOR="red">&#39; + element.date + &#39;</FONT>&#39; + "<BR>" + &#39;<FONT 
SIZE="1">&#39; + element.appointments + &#39;</FONT>&#39;; 
}

The input mechanism here is very primitive, the user adds a new line tag (< ;BR>), otherwise they will all appear on one line. Finally innerHTML is the date data (element.date) and appointment designation (element.appointments) of connecting links.
 TODAY The HTML component (today.htc) is very similar to the ANYDAY component (day.htc). The only difference is that the background-color in the style sheet is pink instead of lightyellow, and the font color is blue instead of red.
Notice that the current date in the calendar is pink with blue background.

The above is the fifth content of HTML COMPONENTS. For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Orbital Mechanics (or How I Optimized a CSS Keyframes Animation)Orbital Mechanics (or How I Optimized a CSS Keyframes Animation)May 09, 2025 am 09:57 AM

What does it look like to refactor your own code? John Rhea picks apart an old CSS animation he wrote and walks through the thought process of optimizing it.

CSS Animations: Is it hard to create them?CSS Animations: Is it hard to create them?May 09, 2025 am 12:03 AM

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframes CSS: The most used tricks@keyframes CSS: The most used tricksMay 08, 2025 am 12:13 AM

@keyframesispopularduetoitsversatilityandpowerincreatingsmoothCSSanimations.Keytricksinclude:1)Definingsmoothtransitionsbetweenstates,2)Animatingmultiplepropertiessimultaneously,3)Usingvendorprefixesforbrowsercompatibility,4)CombiningwithJavaScriptfo

CSS Counters: A Comprehensive Guide to Automatic NumberingCSS Counters: A Comprehensive Guide to Automatic NumberingMay 07, 2025 pm 03:45 PM

CSSCountersareusedtomanageautomaticnumberinginwebdesigns.1)Theycanbeusedfortablesofcontents,listitems,andcustomnumbering.2)Advancedusesincludenestednumberingsystems.3)Challengesincludebrowsercompatibilityandperformanceissues.4)Creativeusesinvolvecust

Modern Scroll Shadows Using Scroll-Driven AnimationsModern Scroll Shadows Using Scroll-Driven AnimationsMay 07, 2025 am 10:34 AM

Using scroll shadows, especially for mobile devices, is a subtle bit of UX that Chris has covered before. Geoff covered a newer approach that uses the animation-timeline property. Here’s yet another way.

Revisiting Image MapsRevisiting Image MapsMay 07, 2025 am 09:40 AM

Let’s run through a quick refresher. Image maps date all the way back to HTML 3.2, where, first, server-side maps and then client-side maps defined clickable regions over an image using map and area elements.

State of Devs: A Survey for Every DeveloperState of Devs: A Survey for Every DeveloperMay 07, 2025 am 09:30 AM

The State of Devs survey is now open to participation, and unlike previous surveys it covers everything except code: career, workplace, but also health, hobbies, and more. 

What is CSS Grid?What is CSS Grid?Apr 30, 2025 pm 03:21 PM

CSS Grid is a powerful tool for creating complex, responsive web layouts. It simplifies design, improves accessibility, and offers more control than older methods.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment