473,779 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

when do I need getPropertyValu e()?

Hi,

Since I can do this

document.defaul tView.getComput edStyle(el, null).height;

why would I ever want to do this

document.defaul tView.getComput edStyle(el,
null).getProper tyValue('height ');

Is there a browser with getComputedStyl e() that cannot do the first way
and hence requires the use of getPropertyValu e()?

Thank you,
Peter

Nov 24 '06 #1
3 7019
VK

Peter Michaux wrote:
Hi,

Since I can do this

document.defaul tView.getComput edStyle(el, null).height;

why would I ever want to do this

document.defaul tView.getComput edStyle(el,
null).getProper tyValue('height ');
The first syntax requires property name in camelCase; the second syntax
takes property name as it is. This way it could be possible to choose
the most convenient way for a particular situation w/o normalizing all
involved names. But as IE currentStyle takes only camelCase anyway, the
second syntax didn't go into wide use.
Also please note that as you are asking for *computed* (current) style,
you are getting normalized value back (how is it internally stored by
UA, so not necessarily how it is indicated in the source). For the
second reason the whole getComputedStyl e interface is used only rather
occasionally for specific tasks - yet for these tasks it is very
useful.

// See the sample:

<html>
<head>
<title>Styles </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<style type="text/css">
body {
color: #000000;
background-color: #FFFFFF;
}
h1 {
background-color: yellow;
}
</style>
<script type="text/javascript">
function init() {
var header = document.getEle mentsByTagName( 'h1')[0];
if ((document.defa ultView)
&& (document.defau ltView.getCompu tedStyle)) {
window.alert(do cument.defaultV iew
.getComputedSty le(header,null) .backgroundColo r);
window.alert(do cument.defaultV iew
.getComputedSty le(header,null)
.getPropertyVal ue('background-color'));
}
else if (header.current Style) {
window.alert(he ader.currentSty le.backgroundCo lor);
}
}
window.onload = init;
</script>
</head>
<body>
<h1>Lorem ipsum</h1>
</body>
</html>

Nov 24 '06 #2
VK

VK wrote:
Also please note that as you are asking for *computed* (current) style,
you are getting normalized value back (how is it internally stored by
UA, so not necessarily how it is indicated in the source). For the
second reason the whole getComputedStyl e interface is used only rather
occasionally for specific tasks - yet for these tasks it is very
useful.
To not be abstract: getComputedStyl e can be used to determine the exact
pixel size of 1em for the given font on the given machine.

Nov 24 '06 #3
Hi VK,

VK wrote:
Peter Michaux wrote:
Hi,

Since I can do this

document.defaul tView.getComput edStyle(el, null).height;

why would I ever want to do this

document.defaul tView.getComput edStyle(el,
null).getProper tyValue('height ');

The first syntax requires property name in camelCase; the second syntax
takes property name as it is. This way it could be possible to choose
the most convenient way for a particular situation w/o normalizing all
involved names. But as IE currentStyle takes only camelCase anyway, the
second syntax didn't go into wide use.
So other than hyphenated vs. camelCase is there any difference. Does
anyone know of a browser bug surrounding this issue where
getPropertyValu e() is the only solution? I would much prefer to use the
first with it's camelCase property.

Thanks,
Peter

Nov 25 '06 #4

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

Similar topics

3
14866
by: Jack Black | last post by:
Using Mozilla 1.4... I need to get the Height and Width of an object (in this case, a parent DIV) for the purpose of creating a textbox of max width and height in the container. Since innerHeight/Width don't work correctly in Mozilla 1.4, I've tried using getComputedStyle as noted in another newsgroup, but with no success; errors tend to range from "Cannot create object in this context" to other various errors... The below sample...
6
5238
by: Louise | last post by:
Hi I have written an HTML pages which does not have any colour specifying tags as far I know. When I view this in an Microsoft internet explorer browser it appears with a white background and black text but when I change Windows start menu->settings->control panel ->display -> appearance and change scheme to 'High Contrast Black' the background in the browser changes to black and the text to white. I understand that the windows scheme...
26
2479
by: Simon | last post by:
I'm doing a survey. When do you think GNU/Linux will be ready for the average Joe? What obstacles must it overcome first?
22
2358
by: Bradley | last post by:
Has anyone else noticed this problem? I converted the back-end to A2000 and the performance problem was fixed. We supply a 97 and 2000 version of our software so we kept the backend in A97 to make upgrading simple for users. We've done it like that for years but a new client has been having severe performance issues... solved by converting the backend to 2000. -- regards, Bradley
6
2314
by: Nathan Sokalski | last post by:
I am using a DataSet as the DataSource of a DataList in my code. The SQL used to get the data from the database begins with: SELECT members.organization,artists.artist,artists.email,artists.website,members.email FROM members INNER JOIN artists ON members.memberid=artists.memberid WHERE Notice that both tables involved in the SELECT statement have a field named
2
16783
by: Pugi! | last post by:
I would like to obtain the the position of backgroundimage of a div because I use it for animation. The following code works for Internet Explorer (takes the else if) and returns positionx '10px' and position y '25px' (the backgroundPosition doesn't work). Opera follows the first road (if) and returns '10px 25px'. Firefox follows the same road (first if) as Opera but returns a blank. if (window.getComputedStyle) { var stijl =...
44
8274
by: Smokey Grindle | last post by:
I have a list box on my form, but I need to databind it to a data table that is a private member of the form's class... so I basically have Public Class MyForm priate m_MyTable as new datatable End Class now where would I properly dispose of this? In the finalize method? I am loading the data for the table in a subroutine that is executed at form load, of course all the commands tied to it are wrapped in using blocks, but
15
2175
by: Jess | last post by:
Hello, Sometimes declarations are all what we need when we define/declare classes (or functions?), but sometimes we need definitions. I learned that if we define a class (B) that has an object (a_obj) of a class type (A), then we need to define A as well, but if B has a pointer to A, then we only need to forward declare A. I was told this is because the compiler needs to see the implemenation of A when allocating memory for a_obj. ...
0
2009
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ((string)(this.GetPropertyValue("Address1")));
0
10139
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10075
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,...
0
9931
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 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...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
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...
0
6727
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();...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
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...

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.