On Feb 12, 1:42 pm, Peter van der Zee <[email protected]> wrote:
> On Sat, Feb 12, 2011 at 1:56 PM, clothears <[email protected]> wrote:
> > Are there any issues with setting window.innerWidth? Using Safari
> > 5.0.3 Mac I'm finding that if I set it to some value, then that is the
> > value it subsequently reports, however much the window is resized.
>
> I would regard innerWidth as a read-only property. I know there are various
> inconsistencies with innerWidth between browsers, but don't know them by
> heart. Maybe somebody else (or google) does.
Hummmm, yes I see now that Flanagan regards them as read-only. I'll
have to rethink that aspect.
> > It appears that if I set some value using CSS, then I am unable to
> > read that value with JavaScript. I have, instead, to not bother
> > setting it with CSS, but instead to initialise it (to the same value)
> > with JavaScript, and then I find I can read it back correctly. Is this
> > expected behaviour?
>
> Yes. I'm assuming you're trying to read these values through the el.style
> object. This is safe for writing, but not for reading. To read (any
> currently applied style for a specific element), there are two ways to go:
Umm no. If I take as a specific example the left padding of a <div>,
then I was assuming that if I had:
.mystyle { padding-left: 2px;}
and that this was applied to a div with id="xyz", I could read the
value by just doing:
pad = parseInt (document.getElementById("xyz").style.paddingLeft);
but it seems not. I can apparently only do that by first explicitly
setting it:
document.getElementById("xyz").style.paddingLeft = pad + "px";
But why can I not read it as above?
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]