Tuesday, December 2, 2008

Coding for Calling Css File using javascript

function select_fun(filename)
{
var file_name_script=filename+".css";
var file_ref=document.createElement("link"); //use for creating link tag
file_ref.setAttribute("rel","StyleSheet");
file_ref.setAttribute("type","text/css");
file_ref.setAttribute("href",file_name_script);
document.getElementsByTagName("head")[0].appendChild(file_ref);//used for appending css link tag to head tag
}

Note:

if u want to call any script file replace "script" by "link" in document.createElement("link");



//coding for changing css style automatically in random using setTimeout()
var i_count_value=0;
var j_count_value=0;
file_name_script='glow.css';
select_fun();
function select_fun()
{
if(file_name_script=='blur.css')
{
i_count_value++;
file_name_script='glow.css';
}
else if(file_name_script=='glow.css')
{
j_count_value++;
file_name_script='blur.css';
}
var file_ref=document.createElement("link");
file_ref.setAttribute("rel","StyleSheet");
file_ref.setAttribute("type","text/css");
file_ref.setAttribute("href",file_name_script);
document.getElementsByTagName("head")[0].appendChild(file_ref);
if(j_count_value>=16)
{
history.go(); //used to refresh page
}
var a=setTimeout("select_fun()",800);
}

//css files

//blur.css
h5
{
height:50;
width:400;
font-size:30pt;
font-weight:bold;
color:orange;
filter:Blur(Direction=1, Strength=8)
}

//glow.css
h5
{
height:50;
width:400;
font-size:30pt;
font-weight:bold;
filter:Glow(Color=green, strength=6)
}


List of Filter Property Values (Functions)

alpha -- Set transparency properties for an element This filter sets the level of opacity for an element. This can be a constant value, or it can be 'blended' across an element (i.e., an alpha gradient) using a variety of different styles.

blendtrans -- Fade the element into or out of view This dynamic filter is used to fade an element and its content into and out of view: parameters control the speed and duration of the fading effect.

blur -- Blur the element and its content This filter is used to blur the content of an element. Parameters can control the degree of blurring, and the direction in which the blur is applied.

chroma -- Make a single color transparent This filter takes the form filter: chroma(color="rrggbb); , and sets the indicated color to be transparent. Dynamic scripts can use this to change the color that is transparent. The value rrggbb can be either an RGB code (#rrggbb) or a known color name.

dropshadow -- Add a drop shadow to the element text This filter creates a drop shadow effect for the text content of an element. Various supported parameters define the direction and size of the shadow. This is only supported by the div, marquee, span, table, td and th elements.

fliph -- Horizontally flip the element This filter has no parameters and takes the form: filter: fliph(); . This flips or "mirrors" the element horizontally.

flipv -- Vertically flip the element Adds radiance around the outer edge of an element . filter: flipv(); . This flips or "mirrors" the element vertically.

glow -- Add radiance around text letters This filter adds a radiant glow around the text content of an element. The parameter color sets the glow color (e.g. color=green), while the parameter strength sets the size for the glow( zero to 100). This has no effect if a background color or image is applied to the element.

gray -- Render element in grayscale This filter has no parameters and takes the form: filter: gray(); . This transforms the element and content to a grayscale palette.

invert -- Inverts colors in the element This filter has no parameters and takes the form: filter: invert(); . This transforms the element and content such that each color is replaced by the color with the opposite hue, saturation and brightness.

light -- Simulated light source projected on the element This filter creates the effect of a simulated light source shining down on the element content. Parameters define the type of light source (color, shape, strength) and the position of the source.

mask -- Remasks transparent pixels. element This filter takes the selected element content, paints the transparent pixels using the color specified by the color property, and changes all the nontransparent pixels to be transparent. This takes only one parameter, color, to set the color.
redirect -- Allow animation using Microsoft DirectAnimation™ components. This filter Converts the object into a DAImage object which can then be manipulated using Microsoft's DirectAnimation controls. Of course, this requires that the DirectAnimation browser component, be invoked in the Web page. This is typically done by referencing the appropriate DLL using an object element.

revealtrans -- Show or hide an element and its content This filter defines one of 23 defined transitions that can hide or reveal the element content. Parameters define the type of transition, its duration, and the nature of the transition (e.g., stops after one transition loop).

shadow -- Paint a shadow around the element content This filter paints a shadow around the selected element content. Parameters define the color of the shadow, and the direction in which the shadow should be applied.

wave -- Apply a sine-wave distortion to the element This filter applies a sine-wave distortion to the element and its content. Parameters define the magnitude and frequency of the wave, and the strength (amplitude, color, etc.) of the distortion.

xray -- Create X-ray effect This filter has no parameters and takes the form: filter: xray(); . This changes the color depth of the display, and renders the element content in black and white, making it look like a black-and-white x-ray.

No comments: