From Newsgroup: alt.html
On Thu, 22 Aug 2024 09:36:46 +0200, R.Wieser wrote:
Hello all,
I'm appending, using GreaseMonkey, an element to the body of a webpage. Although the appending itself works, the placement of the appended element sometimes causes a problem: it gets placed at the top, over the original contents.
The below URL is an example for when that it happens :
https://bugzilla.mozilla.org/show_bug.cgi?id=335545
I've been able to track the problem back to the '<div id="wrapper">' element, which gets a "position: absolute;" setting (removing/disabeling either the ID or the position moves the appended element back to the bottom, where its supposed to be).
The thing is that I'm looking for a generic (CSS) solution, not a page-specific one.
I've tried several things, including following the above div with another div containing the "clear: both" style, but nothing I try seems to work.
Does anyone have an idea what I would need to use for a generic solution ?
By the way, I've been humoring the thought of going thru all elements and attempt to remove any-and-all "position" settings, but that could be rather time-consuming - and I'm not even sure if it would work.
Regards,
Rudy Wieser
You can't use one fixed method since web pages use different layouts. Your
code will have to at least be adaptive.
Especially due to the fact that, most websites don't use the correct HTML
tags to contain specific kind of content - even for Mozilla, Google, and
Apple sites (Google is obviously the worst, BTW).
e.g. use only or mostly only DIVs instead of ARTICLE, ASIDE, FOOTER, HEADER, MAIN, SECTION, etc.
Meaning that, it's site-specific structured where only that site knows which parts of the page hold specific kind of content, rather than standard structured where all web browsers and all HTML readers can know them.
That being said, the HTML+DOM specifications make it worse by adding custom elements.
In your case, the important part is identifying which element is the base
node which holds all of the basic contents such as header, sidebar, main content, and footer; before deciding where to insert your element.
And in the case of that Mozilla page, you may need to check the position of
the added element. Compare it against the page height. If it's e.g. not
within the bottom 25% of page height, then the element insertion point was incorrect, and further checkings needs to be done to get the correct
insertion point.
--- Synchronet 3.21d-Linux NewsLink 1.2