473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Blank image replacements???

I have a small function that simply swaps image A with image B. The problem
is that in some situations (i don't know why yet) when A and B are swapped,
they simply vanish. Here is the function (with a transition):

<script>
var pictemp=new Image();
function replacemain(id){
if (document.all){
document.images.MainImage.style.filter="blendTrans (duration=2)"
document.images.MainImage.filters.blendTrans.Apply ()
document.images['Image_'+id].style.filter="blendTrans(duration=2)"
document.images['Image_'+id].filters.blendTrans.Apply()
}
pictemp.src=document.images.MainImage.src;
document.images.MainImage.src = document.images['Image_'+id].src;
document.images['Image_'+id].src=pictemp.src;

if (document.all){
document.images.MainImage.filters.blendTrans.Play( )
document.images['Image_'+id].filters.blendTrans.Play()
}

}
</script>

Jul 23 '05 #1
4 1589
Actually here's the function (saw some slight mistakes). Do you have any
ideas why its "blanking" on some IEs?

<script>
function replacemain(id){
var pictemp=new Image();
if (document.all){
document.images.MainImage.style.filter="blendTrans (duration=2)"
document.images.MainImage.filters.blendTrans.Apply ()

document.images['Image_'+id].style.filter="blendTrans(duration=2)"
document.images['Image_'+id].filters.blendTrans.Apply()
}
pictemp.src=document.images.MainImage.src;
document.images.MainImage.src = document.images['Image_'+id].src;
document.images['Image_'+id].src=pictemp.src;

if (document.all){
document.images.MainImage.filters.blendTrans.Play( );
document.images['Image_'+id].filters.blendTrans.Play();
}

}
</script>


"Jon Glazer" <jg***************@adconn.com> wrote in message
news:IQ*******************@fe2.columbus.rr.com...
I have a small function that simply swaps image A with image B. The
problem is that in some situations (i don't know why yet) when A and B are
swapped, they simply vanish. Here is the function (with a transition):

<script>
var pictemp=new Image();
function replacemain(id){
if (document.all){
document.images.MainImage.style.filter="blendTrans (duration=2)"
document.images.MainImage.filters.blendTrans.Apply ()
document.images['Image_'+id].style.filter="blendTrans(duration=2)"
document.images['Image_'+id].filters.blendTrans.Apply()
}
pictemp.src=document.images.MainImage.src;
document.images.MainImage.src = document.images['Image_'+id].src;
document.images['Image_'+id].src=pictemp.src;

if (document.all){
document.images.MainImage.filters.blendTrans.Play( )
document.images['Image_'+id].filters.blendTrans.Play()
}

}
</script>

Jul 23 '05 #2
Jon Glazer wrote:
Actually here's the function (saw some slight mistakes). Do you have any
ideas why its "blanking" on some IEs?

<script>
<script type="text/javascript">
function replacemain(id){
"id" is not a good choice for a variable name. I keep 'em simple:

function replacemain( s ) {
var pictemp=new Image();
Why create pictemp as an image, when you only need it as a string? You
can set its value at the same time and create a variable to hold the
reference to MainImage (keeps code neater...):

var x = document.images['MainImage'];
var y = document.images[s];
var pictemp = x.src;
if (document.all){
You repeatedly test for document.all, but don't use it. I guess the
presumption is that any browser that supports document.all also
supports filters - that's kinda risky. You want to use filters, so test
for them. Since you want to use it more than once, use a boolean:

var haveFilters = (x.filters);

if ( haveFilters ) {
document.images.MainImage.style.filter="blendTrans (duration=2)"
document.images.MainImage.filters.blendTrans.Apply ()

document.images['Image_'+id].style.filter="blendTrans(duration=2)"
document.images['Image_'+id].filters.blendTrans.Apply()
Because we've used simple variable names, this stuff now becomes:

x.style.filter = "blendTrans(duration=2)";
x.filters.blendTrans.Apply();

y.style.filter = "blendTrans(duration=2)";
y.filters.blendTrans.Apply();
}
pictemp.src=document.images.MainImage.src;
document.images.MainImage.src = document.images['Image_'+id].src;
document.images['Image_'+id].src=pictemp.src;


and swapping the images becomes:

x.src = document.images[s].src;
y.src = pictemp;

[...]

et cetera.

Now your function will happily work in IE and Firefox (at least it did
for me). I hope it also fixed your other issue! Sample code below:

<html>
<head><title>Swap Images</title>
<script>
function replacemain(s){

var x = document.images['MainImage'];
var y = document.images[s];
var haveFilters = (x.filters);

if ( haveFilters ) {
x.style.filter = "blendTrans(duration=2)";
x.filters.blendTrans.Apply();
y.style.filter = "blendTrans(duration=2)";
y.filters.blendTrans.Apply();
}

x.src = document.images[s].src;
y.src = pictemp;

if ( haveFilters ) {
x.filters.blendTrans.Play();
y.filters.blendTrans.Play();
}
}
</script>
</head><body>
<img src="a.gif" id="MainImage" width="200" height="50"
onclick="replacemain('notMainImage');">
<br>
<img src="b.gif" id="notMainImage" width="200" height="50">
</body></html>
--
Rob
Jul 23 '05 #3
I tried what you showed below and actually the results are not any
different. If you go to

http://callandermats.adconn.com/cata...d=21&subcat=14

and click on the Other Views area and then open swatches and back and forth
I think you'll eventually get blank replacements.

Any more ideas?

This is what I currently have:
function replacemain(s){
s='Image_'+s;
var x = document.images['MainImage'];
var y = document.images[s];
var haveFilters = (x.filters);

if ( haveFilters ) {
x.style.filter = "blendTrans(duration=2)";
x.filters.blendTrans.Apply();
y.style.filter = "blendTrans(duration=2)";
y.filters.blendTrans.Apply();
}

var pictemp = x.src;
x.src = y.src;
y.src = pictemp;

if ( haveFilters ) {
x.filters.blendTrans.Play();
y.filters.blendTrans.Play();
}
}

"RobG" <rg***@iinet.net.auau> wrote in message
news:Ar*****************@news.optus.net.au...
Jon Glazer wrote:
Actually here's the function (saw some slight mistakes). Do you have any
ideas why its "blanking" on some IEs?

<script>


<script type="text/javascript">
function replacemain(id){


"id" is not a good choice for a variable name. I keep 'em simple:

function replacemain( s ) {
var pictemp=new Image();


Why create pictemp as an image, when you only need it as a string? You
can set its value at the same time and create a variable to hold the
reference to MainImage (keeps code neater...):

var x = document.images['MainImage'];
var y = document.images[s];
var pictemp = x.src;
if (document.all){


You repeatedly test for document.all, but don't use it. I guess the
presumption is that any browser that supports document.all also
supports filters - that's kinda risky. You want to use filters, so test
for them. Since you want to use it more than once, use a boolean:

var haveFilters = (x.filters);

if ( haveFilters ) {
document.images.MainImage.style.filter="blendTrans (duration=2)"
document.images.MainImage.filters.blendTrans.Apply ()

document.images['Image_'+id].style.filter="blendTrans(duration=2)"
document.images['Image_'+id].filters.blendTrans.Apply()


Because we've used simple variable names, this stuff now becomes:

x.style.filter = "blendTrans(duration=2)";
x.filters.blendTrans.Apply();

y.style.filter = "blendTrans(duration=2)";
y.filters.blendTrans.Apply();
}
pictemp.src=document.images.MainImage.src;
document.images.MainImage.src = document.images['Image_'+id].src;
document.images['Image_'+id].src=pictemp.src;


and swapping the images becomes:

x.src = document.images[s].src;
y.src = pictemp;

[...]

et cetera.

Now your function will happily work in IE and Firefox (at least it did
for me). I hope it also fixed your other issue! Sample code below:

<html>
<head><title>Swap Images</title>
<script>
function replacemain(s){

var x = document.images['MainImage'];
var y = document.images[s];
var haveFilters = (x.filters);

if ( haveFilters ) {
x.style.filter = "blendTrans(duration=2)";
x.filters.blendTrans.Apply();
y.style.filter = "blendTrans(duration=2)";
y.filters.blendTrans.Apply();
}

x.src = document.images[s].src;
y.src = pictemp;

if ( haveFilters ) {
x.filters.blendTrans.Play();
y.filters.blendTrans.Play();
}
}
</script>
</head><body>
<img src="a.gif" id="MainImage" width="200" height="50"
onclick="replacemain('notMainImage');">
<br>
<img src="b.gif" id="notMainImage" width="200" height="50">
</body></html>
--
Rob

Jul 23 '05 #4
Jon Glazer wrote:
I tried what you showed below and actually the results are not any
different. If you go to

http://callandermats.adconn.com/cata...d=21&subcat=14

and click on the Other Views area and then open swatches and back and forth
I think you'll eventually get blank replacements.

Any more ideas?


I tried your link with IE 6 on SP 1, it works fine (and also in
Firefox, just for the record). Since I can't reproduce the problem, I
can't provide any more assistance. :-(
--
Rob
Jul 23 '05 #5

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

Similar topics

6
by: Marek Mänd | last post by:
Can the <button><img></button> mutated via CSS so, that the inner image of <BUTTON> would entirely visually become the button itsself - I mean without the outer elements borders and so... ...
5
by: Jerry Schwartz | last post by:
I've cobbled together a script that should load a picture in a new, automatically sized window. Because the image.height and image.width may be 0 if I test them right away, I use setTimeout to loop...
2
by: Michael | last post by:
All, I have a form send a variable to another page. Based on the variable the page will show a different image. I.E. <form METHOD="POST" ACTION="http://mysite.com/photo.htm"> <input...
2
by: Trent | last post by:
Hey All, I am new to javascript and currently coding a site with scripts that are beyond my level of understanding. The problematic page has thumbnail images that can be clicked on to zoom in....
11
by: Alan Silver | last post by:
Hello, I am using this validator on a textbox, and have discovered that if I set the InitialValue property, then the validator correctly fires if the user does not change the initial value of...
1
by: D Kav | last post by:
The SQL SERver 2005 Standard Edidtion install CD and the MSDN CD distributed at the SQLServer Launch in Chicago are blank. Has anyone else had this problem and or requested replacements? If so,...
1
by: karen987 | last post by:
the page below is called "todays newslog" and it automatically draws out news articles posted within a 24 hour period. It is an asp page updated each midnight. During the time Midnight to whenver...
0
by: crankeboy | last post by:
Hi Folks, My setup: Visual Studio Express 2008, VC++, .NET, BitBlt Here is a summary of the problem: - I am trying to copy a bitmap of my main form into a picture box. - To do this, I bitblt...
3
by: simon2x1 | last post by:
the code below will upload image and insert the image name and other variable into the database but i dont want the upload feild to post a blank field and also not to allow any image which is not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.