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


Groups > comp.lang.javascript > #36042

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

Newsgroups comp.lang.javascript
Subject Re: Greasemonkey getComputedStyle doesn't doesn't return the expected-and-confirmed value.
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <q4m2mu$msd$1@gioia.aioe.org>
Date 2019-02-22 00:05 +0100
Message-ID <XnsA9FEDF3F114eejj99@194.109.6.166> (permalink)

Show all headers | View raw


"R.Wieser" <address@not.available> wrote on 21 Feb 2019 in
comp.lang.javascript: 

> 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).
> 
> For that I'm using the following line :
> 
>   if (window.getComputedStyle(aElements[i]).getPropertyValue("position")
>   == 'fixed') {
> 
> But for some reason it doesn't find elements which are floating, but

'fixed' is not the same as 'floating'.

Try using '.getPropertyValue':

===============
<div style='position:relative;'>first</div>
<div style='position:fixed;'>second</div>

<script>
  const x = document.querySelectorAll('div');

  for (let i=0; i<x.length; i++) {
     let y = window.getComputedStyle(x[i]);
     let z = y.getPropertyValue("position");
     if ( z == 'fixed' ) console.log('Found text: ', x[i].innerHTML );
  };
</script>
===============


> 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).
> 
> 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
> 
> Regards,
> Rudy Wieser
> 
> 
> 



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

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