Coordinate help - Post ID 199055

User 464893 Photo


Ambassador
1,611 posts

I am trying to accurately get the coordinates of any size web page. I am using a screen coordinate get but pages often have scrolls that throw that out making it necessary to have offsets.

Any ideas would be most welcomed. It all comes down to precise positioning of any object on a page be it an image, division whatever.
A enumerated x and y ruler overlay is a possibility not auto like I am after but would do a good job. The difference between VSD and the Editor. VSD places objects where you want. With the editor it is trial and error to get a precise position. I know the split screen helps.

I will let you guess as to why but a good working idea will be rewarded

The Guy from OZ


User 184085 Photo


Ambassador
1,707 posts

At first blush could n,t you reference the top left corner of the page as 0,0 and work down, right from there?
Volunteering to help :)
http://www.tbaygeek.ca
My HTML play area
http://www.tbaygeek.ca/test/
User 464893 Photo


Ambassador
1,611 posts

Yes David I do, trouble is once the page is longer than one screen the bottom of the screen is still given as
screen size, not taking the fact that the page is scrolled down.
The Guy from OZ


User 187934 Photo


Senior Advisor
20,266 posts
Online Now

So you need to define a wrapper to hold the elements that way everything will be inside the wrapper and the page will scroll to the bottom of it.:)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 464893 Photo


Ambassador
1,611 posts

I thought of that, problem being not every page is going to have one. I could insert one I guess but that would either have to be removed after or kept.

I have no problem at all getting a cursor position on a screen but with a long page I am now using two readings one for the cursor position and one for say top of the element position. That works as I can make the necessary calculations it is viable but not elequant.

I thought I was on a winner with some created grid pattern overlay but it had no enumeration and was harder to use than the present method. A overlay of a ruler for x and y directions would be good but it has to suit what ever page it is added too. I am gathering ideas, I may have to delve into programming Javascript/Jquery after all. One thing I have been avoiding.

I will get it eventually. Thanks by the way Eric I will investigate the wrapper idea. I thought a container the size of the page would do but no.

Problem I am using a client side program to manipulate what is basically a serverside object, water and oil

Keep with the ideas coming you know what they say about two heads.
The Guy from OZ


User 187934 Photo


Senior Advisor
20,266 posts
Online Now

Could you get the page size by declaring a variable after adding the dimensions of all the elements together then add in the needed padding? Or instead of padding place empty blocks around all the elements.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 464893 Photo


Ambassador
1,611 posts

Possible but imagine some ones page that requires an element added in a precise position. The process needs to be externally controlled. I am thinking of creating a window that overlays the one being worked on. Bit of overkill.

I know I am impossible. Taking the vertical measurement. I can get a accurate result so far by getting the top of the scroll bar added to the top of the element, the program calculates the actual value taking any offsets caused by the browser window into account.

I have done a lot of Googling the possibilities and now can overlay a grid but without enumeration it is impractical and does require temporarily adding css to a page.

The Guy from OZ



Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.