/    Sign up×
Community /Pin to ProfileBookmark

DIV Transparency Issue

I am hopeing that some of you have familiarity with the scriptaculous JavaScript framework. I posted about this issue on their Google Group, but I never got a response.

I am attempting to perform a DIV fading effect for some visual notifications in my AJAX scripts. Basically it consists of 3 DIVs. One as a container, a second as a transparent background, and a third with a 100% opacity message or image. The effect works great in FireFox and other standards browsers, but it fails miserably in IE6 and IE7. I need to figure out why IE has such a hard time with it. I know IE sucks as a browser, but I need cross browser compatibility.

I have tried just about everything I can think of, but I can’t seem to get it to work. If any of you know of a way of simulating this effect in IE, please let me know.

Below is a sample code page I put together to demo the problem. If you don’t want to download the libraries to get it to work use the provided link ([url]http://www.sanityloss.com/_test/_testfade.html[/url]) to my webspace to see the issue. Remember, it works in standards browsers (I haven’t tried all of them.), but fails in IE.

[CODE]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>

<head>
<meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1″>
<meta name=”author” content=”Kaleb”>

<title>Untitled 1</title>

<script src=”./scripts/js/prototype.js” type=”text/javascript”></script>
<script src=”./scripts/js/scriptaculous.js” type=”text/javascript”></script>

<script type=”text/javascript”>
function start() {
// JavaScript Document

var contact_cDiv = Builder.node(‘div’, {id:’contactContainerDiv’,style:’display:none; position:absolute’})

var contact_tDiv = Builder.node(‘div’, {id:’contactTransBackground’,style:’background-color:#FF0000; position:absolute’});

var contact_sDiv = Builder.node(‘div’, {id:’contactStatusMsg’,style:’position:absolute’});

contact_cDiv.appendChild(contact_tDiv);
contact_cDiv.appendChild(contact_sDiv);
document.body.appendChild(contact_cDiv);

Element.update($(contact_sDiv), “<table align=”center” border=”0″ cellpadding=”0″ height=”100%” valign=”middle” width=”100%”>” +
” <tr>” +
” <td><p id=”confirm_sent”>Test Message</p></td>” +
” </tr>” +
“</table>”);

Element.setStyle($(“confirm_sent”), {
color: “#000000”,
fontWeight: 900,
margin: “0px 0px 0px 0px”,
textAlign: “center”
});

Element.setOpacity(contact_sDiv, 1);

var mForm = $(‘mail’);

// window.alert(Element.getWidth(document.getElementsByName(“name”)[0])+”px”);
Element.setStyle(contact_cDiv, {
left: “10px”,
height: “500px”,
top: “10px”,
width: “500px”
});

Element.setStyle(contact_tDiv, {
height: “100%”,
width: “100%”
});

Element.setOpacity(contact_tDiv, 0.5);

Element.setStyle(contact_sDiv, {
height: “100%”,
width: “100%”
});

Effect.Appear(contact_cDiv, {duration:2.0, queue:’end’});
Effect.Fade(contact_cDiv, {duration:2.0, queue:’end’});
}
</script>
</head>

<body onload=”start()”>

</body>
</html>[/CODE]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KorJun 24.2007 — There is nothing wrong with the IE. If you test you page with the FF javascript console opened you will notice that there is an endless loop while the browsers tries again and again to find a certain object (m_oFlashObject) or to activate that object's prototype. FF somehow manage to keep in background that error, while IE gets it as a lack of memory, or something like that...

For me... I don't trust the "ready-made" libraries. They will always bring an error or another, as javascript is quite a complex language and there are still important differences beteen browsers. In fact there is no browser which is entirely "W3C compatible", thus all the javascript codes must be done "by hand".
Copy linkTweet thisAlerts:
@ktuimalaauthorJun 24.2007 — I don't have any code of that nature in my script. I have run the script hundreds of times using FF and the Error Console, and there are no errors. The problem I am experiencing is that when the DIV layers fade in in IE, the text of the message is white until the effect is done. You must be looking at an error from another page in the console.
Copy linkTweet thisAlerts:
@KorJun 24.2007 — Strange. First time when tested the page, I saw an error. Probably was my mistake, as long as I have more tabs opened in the same FF browser.

Anyway, as I said, I don't trust "pre-made" javascript libraries as scriptaculous. If time, I might build that crossbrowser effect for you in a much lighter way. It is very hard to de-bug a scriptaculous code, as you are dealing with a long library and code lines.

You may also contact the scriptaculous programmers and signal this as a bug. They are probably the only one who can handle their own codes
Copy linkTweet thisAlerts:
@ktuimalaauthorJun 24.2007 — Thanks Kor,

Do you know if this effect is possible in IE? I was messing with some nested DIVs with my own code, and it seems that the IE rendering engine can't handle more than one DIV layer when "fading" the parent DIV. If I take out the transparent layer, everything works fine, but then that defeats my purpose.
×

Success!

Help @ktuimala spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...