473,466 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problem with bgsleight.js

Hi!
I'm trying to make a transparent background in a table, but it's just
not working out for me! I've found this script on a site, hacked
version of sleight.js. Which I refer to in my html. It's kind of
working I guess, it seems it replaces my background.png by x.gif, but I
just can't figure out what I'm doing wrong and why this is happening.
Is it my png that is saved wrong or should I link differently to my
background-image?

if (navigator.platform == "Win32" && navigator.appName == "Microsoft
Internet Explorer" && window.attachEvent) {
window.attachEvent("onload", alphaBackgrounds);
}

function alphaBackgrounds(){
var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
for (i=0; i<document.all.length; i++){
var bg = document.all[i].currentStyle.backgroundImage;
if (itsAllGood && bg){
if (bg.match(/\.png/i) != null){
var mypng = bg.substring(5,bg.length-2);
document.all[i].style.filter =
"progid:DXImageTransform.Microsoft.AlphaImageLoade r(src='"+mypng+"',
sizingMethod='scale')";
document.all[i].style.backgroundImage = "url('x.gif')";
}
}
}
}

Dec 20 '05 #1
2 2391
caroliena wrote:
I'm trying to make a transparent background in a table, but it's just
not working out for me! I've found this script on a site, hacked
version of sleight.js. Which I refer to in my html. It's kind of
working I guess,
Guess again.
it seems it replaces my background.png by x.gif,
As it also should. And what else did you expect that did not work?
but I just can't figure out what I'm doing wrong and why this is
happening.
You are copying nonsensical code from somewhere without having a
minimum clue yourself.
Is it my png that is saved wrong or should I link differently to my
background-image?
Perhaps. <URL:http://jibbering.com/faq/#FAQ4_43>
if (navigator.platform == "Win32" && navigator.appName == "Microsoft
Internet Explorer" && window.attachEvent) {
window.attachEvent("onload", alphaBackgrounds);
}

function alphaBackgrounds(){
var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
<URL:http://pointedears.de/scripts/test/whatami>
var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
for (i=0; i<document.all.length; i++){
var bg = document.all[i].currentStyle.backgroundImage;
if (itsAllGood && bg){
if (bg.match(/\.png/i) != null){
var mypng = bg.substring(5,bg.length-2);
document.all[i].style.filter =
"progid:DXImageTransform.Microsoft.AlphaImageLoade r(src='"+mypng+"',
sizingMethod='scale')";
document.all[i].style.backgroundImage = "url('x.gif')";
}
}
}
}


Post code indented with spaces, not tabs. The above corrected and
pretty-printed, yet untested (I have no IE here):

var len;
if (document.all && (len = document.all.length))
{
for (var i = 0; i < len; i++)
{
var
o = document.all[i],
bg = o.currentStyle.backgroundImage;

if (bg)
{
if (/\.png/i.test(bg))
{
var f;
if ((f = o.filters))
{
var mypng = bg.replace(/^\s*url\((.+)\)\s*/, "$1");
f = f.item("DXImageTransform.Microsoft.AlphaImageLoade r");

if (f)
{
f.src = mypng;
f.sizingMethod = 'scale';
f.enabled = true;
}
}

o.style.backgroundImage = 'url(x.gif)';
}
}
}
}
Read the fine manual:

<URL:http://msdn.microsoft.com/workshop/author/filter/filters.asp>
PointedEars
Dec 20 '05 #2
Thomas 'PointedEars' Lahn said the following on 12/20/2005 3:21 PM:
caroliena wrote:

I'm trying to make a transparent background in a table, but it's just
not working out for me! I've found this script on a site, hacked
version of sleight.js. Which I refer to in my html. It's kind of
working I guess,

Guess again.


Post code indented with spaces, not tabs. The above corrected and
pretty-printed, yet untested (I have no IE here):

var len;
if (document.all && (len = document.all.length))
{
for (var i = 0; i < len; i++)
{
var
o = document.all[i],
bg = o.currentStyle.backgroundImage;


And what, pray tell, makes you believe that because the browser supports
document.all that it supports currentStyle or .backgroundImage?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 20 '05 #3

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

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
0
by: Refky Wahib | last post by:
Hi I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million concurrent...
9
by: Sudesh Sawant | last post by:
Hello, We have an application which communicates using remoting. There is a server which is a Windows Service. The server exposes an object which is a singleton. The client is a Web Application...
117
by: Peter Olcott | last post by:
www.halting-problem.com
17
by: Jon Slaughter | last post by:
I'm having a little trouble understanding what the slicing problem is. In B.S.'s C++ PL3rdEd he says "Becayse the Employee copy functions do not know anything about Managers, only the Employee...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
1
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...
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.