Reply
Find Position Of Object And Display It?
Old 06-30-2009, 07:39 PM Find Position Of Object And Display It?
Physicsguy's Avatar
Extreme Talker

Posts: 164
Name: Physicsguy
Location: On Earth
Trades: 0
Hi again,

How would you make a script that displayed an object's X and Y coordinates in a text box?

Say I made a draggable DIV. Each time I let go of it, how would I make a text box or two display where it is on the page? More specifically, the X and Y positions?

What I'm doing is making a website editor. I want it to be a drag n' drop interface, where you drag a DIV around, changing it's size and position, and a text box showing where it is on the page. Like my generators, the generator uses those coordinates to determine the margins for the CSS file is makes.

Something like this, except it outputs 4 values, the Top Right Bottom Left values.

So instead of outputting:

margin: 0px 240px;

it would output:

margin: 0px 120px 0px 120px;

Is there a way to do this? If so, I need it!

Thanks,

Physicsguy

Last edited by Physicsguy; 06-30-2009 at 07:43 PM..
Physicsguy is offline
Reply With Quote
View Public Profile Visit Physicsguy's homepage!
 
 
When You Register, These Ads Go Away!
Old 06-30-2009, 10:19 PM Re: Find Position Of Object And Display It?
vangogh's Avatar
Post Impressionist

Posts: 9,660
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
You might want to take a look at xray, which is a bookmarklet that does some of what you want to do. It does give the margin and padding for each side so it's in the code somewhere. Add thexray.js to the end of the url in the link above and you can see the javascript code they're using.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 07-01-2009, 10:52 AM Re: Find Position Of Object And Display It?
Physicsguy's Avatar
Extreme Talker

Posts: 164
Name: Physicsguy
Location: On Earth
Trades: 0
Hmmm... That doesn't seem to work the way I want it to...

I mean something all visitors can use, without having to use a laggy button.

I don't mean anything you click, but if you have to click it that's okay. Just a text box displaying the margins automatically, on-page.

Here's where it actually will come into play: http://www.execulink.com/~kayes/phys...ropeditor.html

Last edited by Physicsguy; 07-01-2009 at 11:06 AM..
Physicsguy is offline
Reply With Quote
View Public Profile Visit Physicsguy's homepage!
 
Old 07-02-2009, 06:21 AM Re: Find Position Of Object And Display It?
Novice Talker

Posts: 14
Name: workhomeforum
Trades: 0
You should probably work with an absolute position and therefore you need to use Top and Left properties.
__________________
work from home, discussions
workhomeforum is offline
Reply With Quote
View Public Profile
 
Old 07-02-2009, 10:10 AM Re: Find Position Of Object And Display It?
Physicsguy's Avatar
Extreme Talker

Posts: 164
Name: Physicsguy
Location: On Earth
Trades: 0
What does that mean? How do I do that?

BTW somebody told me that I could use the browser window size minus a few pixels (the border on the browser) minus the width of the shape to get the margins. So:

Browser Window Width - 6px - [width of box] = Margins.

Is this correct?
Physicsguy is offline
Reply With Quote
View Public Profile Visit Physicsguy's homepage!
 
Old 07-03-2009, 06:33 PM Re: Find Position Of Object And Display It?
Physicsguy's Avatar
Extreme Talker

Posts: 164
Name: Physicsguy
Location: On Earth
Trades: 0
Nobody?
Physicsguy is offline
Reply With Quote
View Public Profile Visit Physicsguy's homepage!
 
Old 07-06-2009, 08:12 PM Re: Find Position Of Object And Display It?
vangogh's Avatar
Post Impressionist

Posts: 9,660
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
With the script I linked to I just meant you might be able to find what you wanted in their code. That script is reading the margins of elements and displaying them so it has to be in there.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 07-06-2009, 08:14 PM Re: Find Position Of Object And Display It?
Physicsguy's Avatar
Extreme Talker

Posts: 164
Name: Physicsguy
Location: On Earth
Trades: 0
Maybe I haven't explained quite what I want.

I need the script to read the width of a certain object, do some math functions, and display it when you click 'Generate' or that sort of thing. XRAY isn't quite what I'm looking for, though it is helpful.
Physicsguy is offline
Reply With Quote
View Public Profile Visit Physicsguy's homepage!
 
Reply     « Reply to Find Position Of Object And Display It?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.13544 seconds with 13 queries