/    Sign up×
Community /Pin to ProfileBookmark

Javascript and Opera

Hi

I came across a strange problem. I have developed a script to fade a table and images in and out. But here is the problem it works fine on IE and Firefox, but on Opera when the page opens with onload, the image does not fade in but when i refresh that page the image does fade in.

Can any body tell me why and how it can be fixed.

Thanks

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorDec 01.2006 — A page can not opens [I]with onload[/I]. onload is an [B]event[/B] which triggers a function [I]after[/I] the page loads.

Anyway... can we see the code? Or the significant part of it? Or an example, a link?
Copy linkTweet thisAlerts:
@gogelpotauthorDec 01.2006 — Yes you right Kor. the page gan not open onload my mistake in communicating it correct.

Here is the code (soMe of it) Hope it will help

[CODE]
<script language="JavaScript1.2">

function browser(id){
var brow=((navigator.appName));
if (brow != "Microsoft Internet Explorer"){
shiftOpacity(id, 2000);
}
else {
imageFadeIn('about');
}
}

function shiftOpacity(id, millisec) {

//if an element is invisible, make it visible, else make it ivisible

if(document.getElementById(id).style.opacity == 0) {

opacity(id, 0, 100, millisec);

}
else {
opacity(id, 100, 0, millisec);
}

}

function opacity(id, opacStart, opacEnd, millisec) {

//speed for each frame

var speed = Math.round(millisec / 100);

var timer = 0;

//determine the direction for the blending, if start and end are the same nothing happens

if(opacStart > opacEnd) {

for(i = opacStart; i >= opacEnd; i--) {

setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); timer++;
}

}
else if(opacStart < opacEnd) {
for(i = opacStart; i <= opacEnd; i++)
{
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
timer++;
}
}

}

//change the opacity for different browsers

function changeOpac(opacity, id) {
var object = document.getElementById(id).style;
object.opacity = (opacity / 100);
object.MozOpacity = (opacity / 100);
object.KhtmlOpacity = (opacity / 100);
object.filter = "alpha(opacity=" + opacity + ")";
}

function imageFadeIn(img) {
if ( document.getElementById(img))
{
img.opacity = 0;
setOpacity(img, 10, 100);
}

}

function setOpacity (imgName, step, delay) {

var img = document.getElementById(imgName);
if (img) img.filters.alpha.opacity = step;
if (step > 0 && img.filters.alpha.opacity < 100 || step < 0 && img.filters.alpha.opacity > 0) {
step += step;
setTimeout('setOpacity("' + imgName + '",' + step + ', ' + delay + ')', delay);
}
}

</script>

</head>

<body bgcolor=#FF9933 onload="browser('about')">
<img class='back' src="3D.jpg" width="980" height="600" border="0">

<table id='about' class='abouttext'>
<tr>

<td>

[/CODE]
×

Success!

Help @gogelpot 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 5.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...