spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column68


Introduction to Filters in IE 5.5 and Up

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Scripting Filters

The filters attached to an object are grouped under the filters collection. The filters collection can be accessed like any other object collection. One method is through the filter index in the collection. To enable the first filter, for example, of an object with ID=mydiv, you can use the item array:


mydiv.filters.item(0).enabled = true;

Another method is to specify the item's index by its name. Let's take our previous example and add a little script that will enable the DropShadow filter and disable the Engrave filter. Here is the code, followed by its result:


<DIV ID="mydiv" STYLE="width: 40%; filter:
 progid:DXImageTransform.Microsoft.engrave()
 progid:DXImageTransform.Microsoft.DropShadow(color='red',
 OffX=3, OffY=2)">
<IMAGE SRC="bicycle.gif"><FONT COLOR="blue">In this page we explain
 the basics of using filters.</FONT>
</DIV>
<SCRIPT LANGUAGE="JavaScript">
<!--
mydiv.filters.item(1).enabled = 1;
mydiv.filters.item("DXImageTransform.Microsoft.engrave").enabled = 0;
// -->
</SCRIPT>

In this page we explain the basics of using filters.

Notice that the Engrave filter is disabled in the script, and indeed the DIV element is not engraved.

Each filter supports its own properties and methods. The filter's properties are set during its definition and can be modified by a script. Let's modify the shadow color above from red to tan, inside the script:


<DIV ID="mydiv1" STYLE="width: 40%; filter:
 progid:DXImageTransform.Microsoft.engrave()
 progid:DXImageTransform.Microsoft.DropShadow(color='red',
 OffX=3, OffY=2)">
<IMAGE SRC="bicycle.gif"><FONT COLOR="blue">In this page we explain
 the basics of using filters.</FONT>
</DIV>
<SCRIPT LANGUAGE="JavaScript">
<!--
mydiv1.filters.item(1).enabled = 1;
mydiv1.filters.item("DXImageTransform.Microsoft.engrave").enabled = 0;
mydiv1.filters.item("DXImageTransform.Microsoft.dropshadow").color
 = "tan";
// -->
</SCRIPT>

In this page we explain the basics of using filters.

Next: How to use the filter property

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: September 11, 2000
Revised: September 11, 2000

URL: http://www.webreference.com/js/column68/4.html