Ok, I tried simply everything that came to my mind and now I ran out
of ideas, but to the point - take a look at the code below
// GetStyle returns given style value (works fine)
document.getEle mentById("inner ").style.backgr oundColor =
GetStyle("box", "backgroundColo r");
document.getEle mentById("box") .style.backgrou ndColor = "transparen t";
<div id="box" style="width: 100px; height: 100px; background-color:
Red">
<div id="inner" style="width: 50px; height: 50px"></div>
</div>
What this code do - it retrieves "background-color" style from "box"
element, assigns it to "inner" and then "box" background gets
transparent. Now the funny part - it works in every browser, except
Opera, where both elements gets transparent background. What's even
more funny, when I replace GetStyle(...) with string "Red" it works
fine (GetStyle also returns string). Can someone explain me what is
going on? It's so illogical that I'm starting to think that maybe this
is a bug in Opera..
Thanks for any help,
P. 9 1275
On Apr 22, 12:52 am, Piotr K wrote:
Ok, I tried simply everything that came to my mind and now I ran
out of ideas, but to the point - take a look at the code below
// GetStyle returns given style value (works fine)
document.getEle mentById("inner ").style.backgr oundColor =
GetStyle("box", "backgroundColo r");
document.getEle mentById("box") .style.backgrou ndColor = "transparen t";
<div id="box" style="width: 100px; height: 100px; background-color:
Red">
<div id="inner" style="width: 50px; height: 50px"></div>
</div>
What this code do - it retrieves "background-color" style
from "box" element, assigns it to "inner" and then "box"
background gets transparent. Now the funny part - it works
in every browser, except Opera, where both elements gets
transparent background. What's even more funny, when I
replace GetStyle(...) with string "Red" it works fine
(GetStyle also returns string). Can someone explain
me what is going on? It's so illogical that I'm starting
to think that maybe this is a bug in Opera..
Thanks for any help,
I don't know what help you expect. You have not included the code
necessary for anyone else to even attempt to reproduce your symptoms,
let alone attribute cause and effect relationships to them. And no
matter how effective you assert your - GetStyle - function to be I bet
most would like to see the code in question and verify its suitability/
reliability for themselves.
Piotr K wrote:
Ok, I tried simply everything that came to my mind and now I ran out
of ideas, but to the point - take a look at the code below
// GetStyle returns given style value (works fine)
document.getEle mentById("inner ").style.backgr oundColor =
GetStyle("box", "backgroundColo r");
What is GetStyle()?
document.getEle mentById("box") .style.backgrou ndColor = "transparen t";
<div id="box" style="width: 100px; height: 100px; background-color:
Red">
<div id="inner" style="width: 50px; height: 50px"></div>
</div>
What this code do - it retrieves "background-color" style from "box"
element, assigns it to "inner" and then "box" background gets
transparent. Now the funny part - it works in every browser, except
Opera, where both elements gets transparent background. What's even
more funny, when I replace GetStyle(...) with string "Red" it works
fine (GetStyle also returns string). Can someone explain me what is
going on? It's so illogical that I'm starting to think that maybe this
is a bug in Opera..
Maybe it is, maybe it isn't. Post the code for GetStyle() and we might
be able to tell.
On 22 Kwi, 12:21, pr <p...@porl.glob alnet.co.ukwrot e:
Piotr K wrote:
Ok, I tried simply everything that came to my mind and now I ran out
of ideas, but to the point - take a look at the code below
// GetStyle returns given style value (works fine)
document.getEle mentById("inner ").style.backgr oundColor =
GetStyle("box", "backgroundColo r");
What is GetStyle()?
document.getEle mentById("box") .style.backgrou ndColor = "transparen t";
<div id="box" style="width: 100px; height: 100px; background-color:
Red">
<div id="inner" style="width: 50px; height: 50px"></div>
</div>
What this code do - it retrieves "background-color" style from "box"
element, assigns it to "inner" and then "box" background gets
transparent. Now the funny part - it works in every browser, except
Opera, where both elements gets transparent background. What's even
more funny, when I replace GetStyle(...) with string "Red" it works
fine (GetStyle also returns string). Can someone explain me what is
going on? It's so illogical that I'm starting to think that maybe this
is a bug in Opera..
Maybe it is, maybe it isn't. Post the code for GetStyle() and we might
be able to tell.
Here's the GetStyle code:
function GetStyle(obj, style) {
obj = document.getEle mentById(obj);
if(style == "opacity") return GetOpacity(obj) ;
if(obj.currentS tyle) return obj.currentStyl e[style];
else if(window.getCo mputedStyle) return getComputedStyl e(obj,
"").getProperty Value(style.rep lace(/[A-Z]/g, function(obj, ch) {return
"-"+style.charAt( ch).toLowerCase ()}));
}
However I don't think this has anything to do with that strange
behaviour. In the example I posted earlier it returns simply "Red", so
in other words
GetStyle("box", "backgroundColo r") == "Red"
When I use GetStyle, the background gets transparent under Opera, but
if I replace it with simply "Red" string everything works fine. I
thought there may be some kind of referencing going on under Opera,
but I tried even copying each character from GetStyle return value to
array and than joining it into completely new string - still the same
effect.
On Apr 22, 3:52 am, Piotr K <piotr.korzenie w...@gmail.comw rote:
document.getEle mentById("box") .style.backgrou ndColor = "transparen t";
"transparen t" is an imaginary value. It was used in W3C docs to
describe an element that has no color property set, like "transparen t
element", but it was not meant to be an actual string to assign to the
style. Now it is supported by some newer browsers due to misreading
some badly written W3C samples. Neither Opera not IE6 are one of them.
Never Ever In Your Life :-) put style rules to their default values by
any explicit assignment: because you never in your life can guess what
explicit assignment is expected by some particular UA (think of the
infamous table element display glitch). Always use empty string
instead: this way any UA will restore what it needs by itself.
document.getEle mentById('box') .style.backgrou ndColor = '';
Piotr K wrote:
Here's the GetStyle code:
function GetStyle(obj, style) {
obj = document.getEle mentById(obj);
if(style == "opacity") return GetOpacity(obj) ;
if(obj.currentS tyle) return obj.currentStyl e[style];
else if(window.getCo mputedStyle) return getComputedStyl e(obj,
"").getProperty Value(style.rep lace(/[A-Z]/g, function(obj, ch) {return
"-"+style.charAt( ch).toLowerCase ()}));
}
However I don't think this has anything to do with that strange
behaviour. In the example I posted earlier it returns simply "Red", so
in other words
GetStyle("box", "backgroundColo r") == "Red"
Not quite. It appears in fact to return '"red"' - that is, a string
containing double quote marks, which is not a sensible input for
style.backgroun dColor. Try this, for example:
alert("*" + GetStyle("box", "backgroundColo r") + "*");
Opera doesn't do it after the value has been set in code to
'transparent', so you may have to do a bit of research to find out when
it occurs. My guess is when you use a named colour.
A troublesome one to spot.
On 22 Kwi, 18:21, pr <p...@porl.glob alnet.co.ukwrot e:
Piotr K wrote:
Here's the GetStyle code:
function GetStyle(obj, style) {
obj = document.getEle mentById(obj);
if(style == "opacity") return GetOpacity(obj) ;
if(obj.currentS tyle) return obj.currentStyl e[style];
else if(window.getCo mputedStyle) return getComputedStyl e(obj,
"").getProperty Value(style.rep lace(/[A-Z]/g, function(obj, ch) {return
"-"+style.charAt( ch).toLowerCase ()}));
}
However I don't think this has anything to do with that strange
behaviour. In the example I posted earlier it returns simply "Red", so
in other words
GetStyle("box", "backgroundColo r") == "Red"
Not quite. It appears in fact to return '"red"' - that is, a string
containing double quote marks, which is not a sensible input for
style.backgroun dColor. Try this, for example:
alert("*" + GetStyle("box", "backgroundColo r") + "*");
Opera doesn't do it after the value has been set in code to
'transparent', so you may have to do a bit of research to find out when
it occurs. My guess is when you use a named colour.
A troublesome one to spot.
You're absolutely right, all because of double quote marks returned by
GetStyle, I can't believe I missed that, thank you sooo much - now
everything works fine :)
Thanks for all responses!
VK wrote:
On Apr 22, 3:52 am, Piotr K <piotr.korzenie w...@gmail.comw rote:
>document.getEl ementById("box" ).style.backgro undColor = "transparen t";
"transparen t" is an imaginary value. It was used in W3C docs to describe
an element that has no color property set, like "transparen t element",
but it was not meant to be an actual string to assign to the style.
Wrong on all accounts, see http://www.w3.org/TR/CSS2/colors.htm...und-properties http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-58190037 http://www.w3.org/TR/DOM-Level-2-Sty...yleDeclaration http://www.w3.org/TR/DOM-Level-2-Sty...CSS2Properties
Now it is supported by some newer browsers due to misreading some badly
written W3C samples. Neither Opera not IE6 are one of them.
Or maybe, just *maybe*, you are simply completely wrong *again* because both
user agents do support that string value. I guess it does not bother you to
be corrected all the time because a simple test -- like
var elemRef = document.body.g etElementsByTag Name("*")[0];
if (elemRef && typeof elemRef.style != "undefined" )
{
elemRef.style.b ackgroundColor = "red";
window.alert("N ow it should have a red background.");
elemRef.style.b ackgroundColor = "transparen t";
window.alert("N ow it should have a transparent background.");
}
-- before making further wild assumptions would have sufficed.
Nevertheless, your stating nonsense has been helpful this time as I could
find out that the `style' property and the shorthand CSS properties (for
example elemRef.style.b ackgroundColor) are in fact supported by W3C DOM
Level 2 CSS and _not_ a (fully) proprietary feature as I thought before.
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
On Apr 22, 10:52 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
wrote:
Wrong on all accounts, see
http://www.w3.org/TR/CSS2/colors.htm...und-properties http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-58190037 http://www.w3.org/TR/DOM-Level-2-Sty...yleDeclaration http://www.w3.org/TR/DOM-Level-2-Sty...CSS2Properties
Some day I will maybe understand how anything written on W3C may force
to work it on browser X. Some day...
I guess it does not bother you to
be corrected all the time because a simple test -- like
var elemRef = document.body.g etElementsByTag Name("*")[0];
if (elemRef && typeof elemRef.style != "undefined" )
{
elemRef.style.b ackgroundColor = "red";
window.alert("N ow it should have a red background.");
elemRef.style.b ackgroundColor = "transparen t";
window.alert("N ow it should have a transparent background.");
}
So it works now, even on IE6? Great. I still highly suggest never use
direct assignments for rule reset: use "" instead. Nobody is obligated
to follow this advise of course.
Nevertheless, your stating nonsense has been helpful this time as I could
find out that the `style' property and the shorthand CSS properties (for
example elemRef.style.b ackgroundColor) are in fact supported by W3C DOM
Level 2 CSS and _not_ a (fully) proprietary feature as I thought before.
Since DOM 1 to be exact. But better later than never :-)
VK wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:
>Wrong on all accounts, see
http://www.w3.org/TR/CSS2/colors.htm...und-properties http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-58190037 http://www.w3.org/TR/DOM-Level-2-Sty...yleDeclaration http://www.w3.org/TR/DOM-Level-2-Sty...CSS2Properties
Some day I will maybe understand how anything written on W3C may force
to work it on browser X. Some day...
It is *implemented as specified*, Often Wrong.
>I guess it does not bother you to be corrected all the time because a simple test -- like
var elemRef = document.body.g etElementsByTag Name("*")[0]; if (elemRef && typeof elemRef.style != "undefined" ) { elemRef.style.b ackgroundColor = "red"; window.alert("N ow it should have a red background."); elemRef.style.b ackgroundColor = "transparen t"; window.alert("N ow it should have a transparent background."); }
So it works now, even on IE6?
Now? Even? It works with *all* IE versions that support the `style'
property, so since version 4.0 (documented and tested). Your attempts to
conceal your cluelessness are even more ridiculous than your clueless
boasting itself is.
Great. I still highly suggest never use direct assignments for rule reset:
use "" instead. Nobody is obligated to follow this advise of course.
I would hope so, because your advice does not present an equivalent solution
at all. Assigning the empty string resets the style property to its initial
value (which ISTM to be a proprietary feature, CMIIW), but the cascade may
cause the computed value of the property to be a completely different one.
>Nevertheless , your stating nonsense has been helpful this time as I could find out that the `style' property and the shorthand CSS properties (for example elemRef.style.b ackgroundColor) are in fact supported by W3C DOM Level 2 CSS and _not_ a (fully) proprietary feature as I thought before.
Since DOM 1 to be exact. But better later than never :-)
Wrong again. W3C DOM Level 1 only reserved the `style' attribute of the
HTMLElement interface for future use, and it did not include a section on
CSS interfaces. Furthermore, W3C DOM Level 1 HTML is rendered (and marked)
obsolete by DOM Level 2 HTML since quite a while. http://www.w3.org/TR/REC-DOM-Level-1...l#ID-011100101 http://www.w3.org/TR/DOM-Level-2-HTML/ ("Status of this document", "Note:")
Someone like you who continuously fails to get the basic facts right should
be *very* slow to boast. Probably someone has told you that before.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Csaba2000 |
last post by:
How can I dynamically resize a button in Opera?
The following code works for both IE 5.5 and NN 6.1,
but Opera 7.01 is not budging. Any ideas?
Thanks,
Csaba Gabor from New York
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
|
by: TheKeith |
last post by:
Is it just me or does opera and ie not render the float style properly?
IE does a sucky job at it, but opera makes a total mess; Mozilla/Firefox
renders it correctly however. I'm just trying to be a good boy following
the html 4.01 strict spec, and taking it a step further by not using
tables for layout, but it's becoming a real pain. You would figure
putting a strict doctype declaration at the top of the page would create
a uniformity in...
|
by: Martin Doyle |
last post by:
Ok, I'm building a JS-based limitless-sublevel dynamic menu and am
making it cross browser as well - 3 packs of aspirin so far and
counting ;)
I'm having a weird rendering problem using Opera 7.51, even though it
displays fine in Mozilla 1.6, Firefox 0.9, Netscape 7.1 and Internet
Explorer 6.0
Hope someone can help!
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I detect Opera/Netscape/IE?
-----------------------------------------------------------------------
The « navigator » object contains strings which
specify the browser and version; however, this is in general not
very genuine. Mozilla (and therefore Netscape 6+) allows this to
be freely set, and Opera and IE allow it to be modified. There
are...
|
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,...
| |
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |