New JSSS Methods and Property

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email
In addition to the three new objects, the world of JSSS offers a new method to help set contextual styles and a new property useful for assigning conditional styles.

Conditional styles are applied depending on the status of other variables, whether it's other style or the value on a form. For example, you could check for the existence of color combinations that are hard to read (such as red on blue) and change the colors to more palatable choices.

The contextual methods enables you to specify styles based on their relation to the position of other tags. Its purpose is the same as the contextual syntax for CSS. You can set all <P> tags under and <H1 > tag to a 14 point typeface and all <P> tags under an <H2> tag to a 1 2 point typeface. This use is applied based on the paragraph's context to the heading tags, not on classes. The preceding example is represented like this:

<style type= "text/javascript ">

con textual (tags. h 1, tags.p) fontSize = " 14pt";
contextual (tags.h2, tags.p). fontSize= "12pt";

</style>

We didn't use document in the styleclefinitions. Why not? Because document is one of the top level documents for a Web page, it is understood. You can use it for clarity, but it's not required.

The apply property is used as shorthand to set the style of a tag or group of styles using a function. For example, consider the following function, which sets a background color for an unspecified tag based on the value of its color.

function setBackground (thisTag) with (thisTag) {

if (color) == "yellow") {

else

backgroundcolor = "blue";
}
If (color == "white"){

backgroundcolor "black";
}
}
}
Nothing changes. All this processing happens when the apply property is referenced during style processing. with (tags) (

Hl.color = "white";

 

H2. color = "yellow "; H3.color= "purple";

tags. H 1. apply = setBackground (tags. H 1); tags. H2. apply setBackground (tags. H2); tags. H3.apply setBackground (tags. H3); This code snippet first sets the color of three heading s tags. Then, it takes each of the tags and applies the rules set forth in the function. In this JSSS definition, the text color is set first, then the background is changed using the setBackground method with the apply property. Listing:

<HTML>
<HEAD>
<TITLE>Apply and JSSS</TITLE>
</HEAD>
<STYLE type=" text/java script">
<!..

function setBackground(thisTag){
with (thisTag)
( if (color== "yellow"){

backgroundColor = "blue";
}
else

 

if (color == "white"){

backgroundColor = "black";
}
}
}

with (tags) {
HI.color = "white", H2. color= "yelow";

H3. color = "purple";
}
tags.Hl.apply setBackground (tags.Hl); tags.H2. apply setBackground (tags.H2); tags.H3. apply setBackground (tags.H3);
//-->
</STYLE>
<BODY bgcolor= "white">
<H1 >This is white on black (Hl)</Hl>
<H2>This is yellow on blue (Ha)</H2>

<H3> This is purple on the default background color </H3>
</Body>
</HTML>



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.