473,699 Members | 3,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

filters.alpha is not a object error

TJO
Below is some sample code that fades div tags that is not working in IE
6.0.29 on xp sp2. Can anyone help see why the if(ie5)
document.getEle mentById(divID) .filters.alpha. opacity lines are not
working ? I cannot find a solution yet.
THanks

<script type="text/javascript" language=javasc ript>

var ie5 = (document.all && document.getEle mentById);
var ns6 = (!document.all && document.getEle mentById);

//fades DIV tag IN
function fadeIn(divID, StartOpacityLev el, fadeStep)
{
if(StartOpacity Level >= 0 && StartOpacityLev el < 100)
{
StartOpacityLev el += fadeStep;
if(ie5) document.getEle mentById(divID) .filters.alpha. opacity =
StartOpacityLev el;
if(ns6) document.getEle mentById(divID) .style.MozOpaci ty =
StartOpacityLev el/100;

setTimeout('fad eIn(\'' + divID + '\',' + StartOpacityLev el + ',' +
fadeStep + ')', 5);
}
}

//fades a DIV Tag IN
function fadeOut(divID, StartOpacityLev el, fadeStep)
{
if(StartOpacity Level > 0 && StartOpacityLev el <= 100)
{
StartOpacityLev el -= fadeStep;
if(ie5) {document.getEl ementById(divID ).filters.alpha .opacity =
StartOpacityLev el;}
if(ns6) document.getEle mentById(divID) .style.MozOpaci ty =
StartOpacityLev el/100;

setTimeout('fad eOut(\'' + divID + '\',' + StartOpacityLev el + ',' +
fadeStep + ')', 5);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input id="Button2" type="button" value="On"
onclick="fadeIn ('mydiv', 0, 10)" />
<input id="Button1" type="button" value="Off"
onclick="fadeOu t('mydiv', 100, 10)" />&nbsp;<br />

<div id="mydiv">
<label for="Text1"></label>
<input id="Text1" type="text" />
<input id="Button3" type="button" value="button" />
</div>
</form>
</body>

Feb 8 '06 #1
6 6350

TJO wrote:
Below is some sample code that fades div tags that is not working in IE
6.0.29 on xp sp2. Can anyone help see why the if(ie5)
document.getEle mentById(divID) .filters.alpha. opacity lines are not
working ? I cannot find a solution yet.
THanks

<script type="text/javascript" language=javasc ript>
The language attribute is deprecated, just stick with the type
attribute:

<script type = "text/javascript">
if(ie5) document.getEle mentById(divID) .filters.alpha. opacity =
StartOpacityLev el;
For Internet Explorer, I have tried the following and it works for me:

var oElem = document.getEle mentById("yourI D");
oElem.style.fil ter = "alpha(opacity= " + opacityValue + ")";
<form id="form1" runat="server">


The form element does not have an attribute called runat

URL:http://www.w3.org/TR/REC-html40/inte...ms.html#h-17.3

Feb 9 '06 #2
TJO
Solved:

It appears that IE *requires* your div tag to have a style attribute
defined. I found that you must have width, height, filter and
-moz-opacity defined in order for my code to work.

style="width:10 0px; height:100px; filter:
alpha(opacity=0 );-moz-opacity:0;"

Feb 9 '06 #3
VK

TJO wrote:
Solved:

It appears that IE *requires* your div tag to have a style attribute
defined. I found that you must have width, height, filter and
-moz-opacity defined in order for my code to work.


<http://msdn.microsoft. com/workshop/author/filter/filters.asp>
<quote>
Almost any object can have filters applied to it. However, the object
that the filter is applied to must have layout before the filter effect
will display. Put simply, having layout means that an object has a
defined height and width. Some objects, like form controls, have layout
by default. All other filterable objects gain layout by setting the
height or width property, setting the position property to absolute,
setting the writingMode property to tb-rl, or setting the
contentEditable property to true.
</quote>

Note that it's "or...or", not "and...and"

You could set only width of your DIV to make alpha filter to work.

-moz-opacity is really an outdated temporary property. You can use for
Gecko the official CSS3 "opacity" property instead.

Feb 9 '06 #4
TJO wrote:
[...] Can anyone help see why the if(ie5)
document.getEle mentById(divID) .filters.alpha. opacity lines are not
working ?
"Does not work" is a useless error description. [psf 4.11]

<URL:http://jibbering.com/faq/#FAQ4_43>
[...]
<script type="text/javascript" language=javasc ript>
The language attribute is deprecated; it can be safely
omitted as long as the `type' attribute value is present.
var ie5 = (document.all && document.getEle mentById); ^^^^^^^^^^^^ var ns6 = (!document.all && document.getEle mentById); ^^^^^^^^^^^^^ //fades DIV tag IN
function fadeIn(divID, StartOpacityLev el, fadeStep)
{
if(StartOpacity Level >= 0 && StartOpacityLev el < 100)
{
StartOpacityLev el += fadeStep;
if(ie5) document.getEle mentById(divID) .filters.alpha. opacity = ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^ StartOpacityLev el;


1. Your markup is not Valid.

<URL:http://validator.w3.or g/>

2. Your feature test is flawed.

For example, Opera and recent Gecko-based browsers (probably including
Netscape 8+) support document.all from the IE DOM to a certain extent
and they support document.getEle mentById() from W3C DOM Level 2 Core.
Yet they would classify as IE(5) in your feature test although they do
not support the `filters' property.

<URL:http://pointedears.de/scripts/test/whatami#inferen ce>

3. Your referencing is error-prone.

document.getEle mentById() can return `null' or an undefined value for
any given ID string, yet you would attempt `filters' property access
in that case which would result in a ReferenceError (e.g.: "null has
no properties").

<URL:http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-getElBId>
However, you use a more recent version of Internet Explorer. Although
I have no explanation as to why, I could be that Internet Explorer 4.0
compatible filters are no longer supported there. You should try the
DirectX filters for IE 5.5+ instead, and if that works, use them as
another alternative with previous feature test.

Another reason might be that the IE 6 SP2 DOM implemented the IE4-compatible
filters with their DirectX names, and since ECMAScript implementations ,
including JScript as implemented in Internet Explorer, are case-sensitive,
the filter's name and identifier could be `Alpha', not `alpha' there.

<URL:http://msdn.microsoft. com/workshop/author/filter/filters.asp>
<URL:http://msdn.microsoft.com/workshop/a...nlevel_Support
<URL:http://msdn.microsoft. com/workshop/author/filter/reference/reference.asp>
<URL:http://msdn.microsoft. com/workshop/author/filter/reference/filters/alpha.asp>

Or your timeout is simply too short; values below 50 (_milliseconds_ )
are known to be unreliable.

Please keep us posted which suggestion helped as existing scripts may have
to be changed to continue working in IE 6 SP2 and not everybody may have a
Windows XP system to test with at hand.
PointedEars
Feb 9 '06 #5
Thomas 'PointedEars' Lahn said the following on 2/9/2006 11:10 AM:
TJO wrote:
[...]
<script type="text/javascript" language=javasc ript>
The language attribute is deprecated; it can be safely
omitted as long as the `type' attribute value is present.
var ie5 = (document.all && document.getEle mentById);

^^^^^^^^^^^^


<snip>
2. Your feature test is flawed.

For example, Opera and recent Gecko-based browsers (probably including
Netscape 8+) support document.all from the IE DOM to a certain extent
and they support document.getEle mentById() from W3C DOM Level 2 Core.
Yet they would classify as IE(5) in your feature test although they do
not support the `filters' property.


Recent Gecko based browsers do not pass an if(document.all ) test even
though they sparsely implement document.all

In the future, rather than pointing and post scripting things, please
endeavor to interleave your replies. It makes reading and following much
simpler.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 9 '06 #6
TJO wrote :
Below is some sample code that fades div tags that is not working in IE
6.0.29 on xp sp2. Can anyone help see why the if(ie5)
document.getEle mentById(divID) .filters.alpha. opacity lines are not
working ? I cannot find a solution yet.
THanks

<script type="text/javascript" language=javasc ript>
Drop language; just use type.

var ie5 = (document.all && document.getEle mentById);
One point about the use of & in XHTML: you need to properly escape the
script block in XHTML, otherwise you'll run into problems.

"In XHTML, the script and style elements are declared as having #PCDATA
content. As a result, < and & will be treated as the start of markup,
and entities such as &lt; and &amp; will be recognized as entity
references by the XML processor to < and & respectively."

4.8. Script and Style elements
http://www.w3.org/TR/2002/REC-xhtml1-20020801/#h-4.8

So, here, you need to address this first if you're using XHTML.
var ns6 = (!document.all && document.getEle mentById);

Your browser detection here is bad, not reliable and not specific. What
you should be detecting is the property support like
- the filters property support
- style.MozOpacit y
- style.opacity
- style.getProper tyValue("-khtml-opacity")

That way, you can make your code working for all browsers which
implement the CSS 3 color module opacity property or their own
proprietary opacity property.

More on this:
Using Object/Feature detection approach: best and overall most reliable
http://www.mozilla.org/docs/web-deve...jectFeatDetect
//fades DIV tag IN
function fadeIn(divID, StartOpacityLev el, fadeStep)
{
if(StartOpacity Level >= 0 && StartOpacityLev el < 100)
{
StartOpacityLev el += fadeStep;
if(ie5) document.getEle mentById(divID) .filters.alpha. opacity =
StartOpacityLev el;
if(ns6) document.getEle mentById(divID) .style.MozOpaci ty =
StartOpacityLev el/100;

setTimeout('fad eIn(\'' + divID + '\',' + StartOpacityLev el + ',' +
fadeStep + ')', 5);
5 milliseconds is way too fast and way too demanding for lots of graphic
cards in use. Anyway, the human eye can not catch, can not distinguish
such fast change, that is, if a graphic card can update opacity as such
fast interval.
}
}

//fades a DIV Tag IN
function fadeOut(divID, StartOpacityLev el, fadeStep)
{
if(StartOpacity Level > 0 && StartOpacityLev el <= 100)
{
StartOpacityLev el -= fadeStep;
if(ie5) {document.getEl ementById(divID ).filters.alpha .opacity =
StartOpacityLev el;}
if(ns6) document.getEle mentById(divID) .style.MozOpaci ty =
StartOpacityLev el/100;

setTimeout('fad eOut(\'' + divID + '\',' + StartOpacityLev el + ',' +
fadeStep + ')', 5);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
As mentioned by others, runat is not valid here.
<input id="Button2" type="button" value="On"
onclick="fadeIn ('mydiv', 0, 10)" />
<input id="Button1" type="button" value="Off"
onclick="fadeOu t('mydiv', 100, 10)" />&nbsp;<br />

<div id="mydiv">
<label for="Text1"></label>
This is weird. The label node is empty; so it's useless, it's unusable,
impossible to use.
<input id="Text1" type="text" />
<input id="Button3" type="button" value="button" />
</div>
</form>
</body>


Here's a full cross-browser working example:

Continuous modification of an image's opacity
http://www.gtalbot.org/DHTMLSection/DynamicOpacity.html

which will work in NS 6.2, NS 7.x, NS 8.x, MSIE 6, Opera 9, Safari 2.x,
Firefox 1.x, Seamonkey 1.x, Mozilla 1.x, Konqueror 3.x, K-meleon 0.8+,
etc. It won't work in MSIE 7 beta 2 because of an already reported bug.

Gérard
--
remove blah to email me
Feb 9 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4745
by: Bryan Harrington | last post by:
Hello all.. I'm working on an application that has a worklist of items for users to work on. I'd like to, based on user security, to filter a worklist based on between 1 and 8 items (i.e., location, category, alpha split). That first part is no problem.. the problem is.. how to then allow that user that is (for example) restricted to work 3 locations, to then further filter that worklist to just one location? Yes.. I can use the ADO...
0
2314
by: dcp | last post by:
I just installed the 4.1.0-alpha-max-nt version of MySql and have just started playing around with it. My first test was to try to create a couple of tables, one with a foreign key constraint. I can't seem to figure out how to drop the foreign key constraint, I read through the docs and it says I need to do a 'show create table <table_name>' to get the internally generated foreign key id, but this does not show up when I do the show...
7
3261
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) CType(local4, Short) = CType(src, Short)
3
17386
by: instruo | last post by:
I'm using the System.Drawing.Bitmap class for loading a 32-bit bmp file which includes an alpha channel. The problem is, when it gets loaded (just using the Bitmap(string filename) constructor), it doesn't bother bringing the alpha along with it. All of the pixels just show "255" as their alpha value and Bitmap.IsAlphaPixelFormat() returns false. I know that the alpha does exist physically and has worked with this exact image in other...
1
968
by: Pedja | last post by:
Hello, I have a problem using IE filters in ASPX page (I use VS.NET 2002 and Windows XP). Namely, it looks like it works only if I set POSITION: absolute for a web control. Otherwise, it doesn't work. If I try the following HTML in my ASPX page: <HTML> <HEAD> <title>WebForm3</title>
8
1677
by: Dooglo | last post by:
How do I check to see if my textbox has a alpha character in it? I don't want alpha characters, numeric only. Thanks Dooglo
6
3653
by: tommaso.gastaldi | last post by:
In a previous post I have been asking about a way to test Alpha Transparency. Bob and Michael have kindly provided some ideas. Here I would like to share the function I have prepared, for the purpose to improve it. Frankly, I am not clear about the exact meaning of some pixel format (max, gdi, etc.) and I hope I have put them under the right "case". I have made only some superficial test and it seems to work. Note that the purpose is...
2
1346
by: maya | last post by:
will FF ever support filters? (as in filter:alpha(opacity: 40) ) thanks..
0
2326
by: CatchSandeepVaid | last post by:
We all know that one-to-one associations are non-lazly fetched but during this fetching the filters are not applied. I debugged hibernate code and found that hibernate finally calls EntityLoader.loadByUniqueKey() method: public Object loadByUniqueKey(SessionImplementor session, Object key) throws HibernateException { return load(session, key, null, null); } I can understand that why filters are not applied because all one-to-one...
0
8706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8633
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8947
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7787
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5891
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4392
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3076
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.