Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #36043

Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value.

From Joao Rodrigues <jr.c.l.js@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value.
Date 2019-02-21 21:51 -0300
Organization Aioe.org NNTP Server
Message-ID <q4nh1h$1dum$1@gioia.aioe.org> (permalink)
References <q4m2mu$msd$1@gioia.aioe.org>

Show all headers | View raw


On 21/02/2019 08:39, R.Wieser wrote:
> Hello all,
> 
> I do not see a GreaseMonkey specific newsgroup, so I'm posting here as the
> next-best thing.
> 
> The problem: I'm using FireFox 52, and am trying to find elements with the
> 'position' is 'fixed' settings (yes, stuff stuck to the top or bottom of my
> screen.  I want to un-stick them).

Jeez, FF 52 is a bit dated now. If I recall correctly, I think even that 
version already supported position 'fixed' and 'sticky' for instance.

> 
> For that I'm using the following line :
> 
>    if (window.getComputedStyle(aElements[i]).getPropertyValue("position") ==
> 'fixed') {

Maybe the problem happens with the Array of elements -> aElements[i]. Or 
maybe the 'fixed' element lacks a 'top: 0' (distance in pixels from the 
top of the document). But that's just guessing.

> 
> But for some reason it doesn't find elements which are floating, but when
> use "inspect element" -> "rules" it does actually show a position: fixed
> entry.
> 
> I did try to execute that above line on a mouse-click event, but it didn't
> find the element than either (indicating that it doesn't seem to be a "DOM
> must be fully loaded first" problem).

I doesn't seem to be that sort of problem.

> 
> Does someone here have an idea of what goes wrong and how to fix it ?
> 
> And by the way, this is a site on which it fails.  For both the purple top
> bar and the green block on the left:
> https://sourcemaking.com/design-patterns-and-tips
> 

The following snippet returned 'fixed' in my FF 65.0.1 on Win10:

const nav = document.querySelector('body > 
div.announcement-block.prom.ga-triggered');
console.log(window.getComputedStyle(nav, null).position); // fixed.

A while ago I've written a Codepen example to fix a menu bar at the top 
of the document, using a similar approach:
<https://codepen.io/jrio/pen/GWmMKN>

HTH

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. "R.Wieser" <address@not.available> - 2019-02-21 12:39 +0100
  Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-02-22 00:05 +0100
    Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. "R.Wieser" <address@not.available> - 2019-02-22 08:59 +0100
      Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. Flng Fck <nothanks@invalid.invalid> - 2019-02-22 09:05 +0100
        Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. "R.Wieser" <address@not.available> - 2019-02-22 10:50 +0100
  Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. Joao Rodrigues <jr.c.l.js@gmail.com> - 2019-02-21 21:51 -0300
    Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. "R.Wieser" <address@not.available> - 2019-02-22 09:29 +0100
  Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. JJ <jj4public@vfemail.net> - 2019-02-22 18:49 +0700
    Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. "R.Wieser" <address@not.available> - 2019-02-22 13:51 +0100
      Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. Update. "R.Wieser" <address@not.available> - 2019-02-22 14:34 +0100
        Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value.Solved. "R.Wieser" <address@not.available> - 2019-02-22 15:12 +0100
      Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. JJ <jj4public@vfemail.net> - 2019-02-23 10:18 +0700
        Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. "R.Wieser" <address@not.available> - 2019-02-23 09:53 +0100
          Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. JJ <jj4public@vfemail.net> - 2019-02-23 18:14 +0700
            Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value. "R.Wieser" <address@not.available> - 2019-02-25 18:53 +0100
              Re: Greasemonkey vs the other ones - iframes "R.Wieser" <address@not.available> - 2019-02-26 10:23 +0100
                Re: Greasemonkey vs the other ones - iframes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-02-26 11:27 +0100
                Re: Greasemonkey vs the other ones - iframes "R.Wieser" <address@not.available> - 2019-02-26 12:54 +0100
                Re: Greasemonkey vs the other ones - iframes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-02-26 19:26 +0100
                Re: Greasemonkey vs the other ones - iframes "R.Wieser" <address@not.available> - 2019-02-27 10:45 +0100
                Re: Greasemonkey vs the other ones - iframes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-02-27 12:09 +0100
                Re: Greasemonkey vs the other ones - iframes "R.Wieser" <address@not.available> - 2019-02-27 12:34 +0100
                Re: Greasemonkey vs the other ones - iframes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-02-28 11:07 +0100
                Re: Greasemonkey vs the other ones - iframes "R.Wieser" <address@not.available> - 2019-02-28 12:46 +0100
                Re: Greasemonkey vs the other ones - iframes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-02-28 22:41 +0100
                Re: Greasemonkey vs the other ones - iframes "R.Wieser" <address@not.available> - 2019-03-01 09:59 +0100
                Re: Greasemonkey vs the other ones - iframes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-03-01 10:55 +0100
                Re: Greasemonkey vs the other ones - iframes "R.Wieser" <address@not.available> - 2019-03-01 11:40 +0100
                Re: Greasemonkey vs the other ones - iframes "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-03-01 16:08 +0100
                Re: Greasemonkey vs the other ones - iframes JJ <jj4public@vfemail.net> - 2019-02-27 00:12 +0700
                Re: Greasemonkey vs the other ones - iframes "R.Wieser" <address@not.available> - 2019-02-27 10:39 +0100

csiph-web