Converting widths to percentage

  • Follow


Hi,
A web page I regularly visit has a bad stylesheet: especially what
ticks me is hardcoded width settings due to which I cant read without
horizontal scroll at a decent font size. What I'm trying to do is
write a greasemonkey script to change all widths to be percentages.

The problem I'm facing is that only a few elements have the "width"
property in their style (js object -> style -> width). A majority have
empty width there, but their *CSS style* (not just the computed style)
shows up as having a hardcoded width - which I'm unable to get at in
the script.  I dont understand how this is possible. Can someone
enlighten me, and help me in getting those widths converted? Many
thanks!

Khan
0
Reply chengiz (20) 3/24/2008 7:40:30 PM

chengiz@my-deja.com wrote:
> A web page I regularly visit has a bad stylesheet: especially what
> ticks me is hardcoded width settings due to which I cant read without
> horizontal scroll at a decent font size. What I'm trying to do is
> write a greasemonkey script to change all widths to be percentages.
> 
> The problem I'm facing is that only a few elements have the "width"
> property in their style (js object -> style -> width). A majority have
> empty width there, but their *CSS style* (not just the computed style)
> shows up as having a hardcoded width - which I'm unable to get at in
> the script.  I dont understand how this is possible. [...]

There is o.style.width, document.defaultView.getComputedStyle(o,
null).getPropertyValue("width"), and o.offsetWidth which is the width
actually used for rendering.  If you post the URL of the "web page" and the
relevant parts of your code, we will see what we can do.


PointedEars
-- 
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
0
Reply Thomas 3/25/2008 12:01:16 AM


1 Replies
418 Views

(page loaded in 0.333 seconds)

Similiar Articles:













7/22/2012 4:20:59 PM


Reply: