473,382 Members | 1,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

js script for div positioning working not like I expected...

Folks,
My script below near-works on both Firefox2 and IE7 (though my end
user base will be Firefox2 intranet users only)... "near-works" means
it does permit me to place my div tag on the screen but not where I
expect.

returnLocation() appears to work - it gives me different numeric
results depending on the location of my id tag'd url.

When I pass these numeric values to place() I would expect that my new
output would overwrite the old output but instead its written
somewhere else on the screen. Can someone tell me why this is the
case?

Cheers!
function place( tagID, across, down )
{
var pointer=returnTagObject( tagID );
pointer.style.position="absolute";

if( across<1 )
{ pointer.style.left = ( pointer.offsetWidth+parseFloat(across) ) +
"px"; }
else
{ pointer.style.left = ( pointer.offsetWidth+across ) + "px"; }

if( down<1 )
{ pointer.style.top = ( pointer.offsetHeight+parseFloat(down) )
+"px"; }
else
{ pointer.style.top = ( pointer.offsetHeight+down ) +"px"; }
return;
}

function returnLocation( tagID )
{ // Return (as a string) the location of tagID (use parseFloat to
reverse it back into integer)
var pointer=returnTagObject( tagID );
return pointer.offsetWidth+":"+pointer.offsetHeight;
}
Dec 26 '07 #1
1 1151
On Dec 26, 10:07*am, Randell_D <fiprojects....@gmail.comwrote:
Folks,
My script below near-works on both Firefox2 and IE7 (though my end
user base will be Firefox2 intranet users only)... "near-works" means
it does permit me to place my div tag on the screen but not where I
expect.

returnLocation() appears to work - it gives me different numeric
results depending on the location of my id tag'd url.

When I pass these numeric values to place() I would expect that my new
output would overwrite the old output but instead its written
somewhere else on the screen. *Can someone tell me why this is the
case?

Cheers!

function place( tagID, across, down )
{
* var pointer=returnTagObject( tagID );
* pointer.style.position="absolute";

* if( across<1 )
* { * * pointer.style.left = ( pointer.offsetWidth+parseFloat(across) ) +
"px"; }
* * * * else
* { * * pointer.style.left = ( pointer.offsetWidth+across ) + "px"; * }

* if( down<1 )
* { * * pointer.style.top = ( pointer.offsetHeight+parseFloat(down) )
+"px"; * * * * * * * *}
* else
* { * * pointer.style.top = ( pointer.offsetHeight+down ) +"px"; * * *}
* return;

}

function returnLocation( tagID )
{ * * * // Return (as a string) the location of tagID (use parseFloat to
reverse it back into integer)
* * * * var pointer=returnTagObject( tagID );
* * * * return pointer.offsetWidth+":"+pointer.offsetHeight;

}- Hide quoted text -

- Show quoted text -
A couple of questions.

So you want a DIV to move to where the user clicks?

Why do you use parseFloat on the if case and not the else? I know that
string concatenation versus addition has tripped me up many times.

And the returnTagObject just does a getElementById I assume?

And what output do you mean? Are you trying to move a DIV and instead
it is creating another DIV?
Dec 26 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Wentink | last post by:
Does anybody have a simple script that let's me popup a picture from a thumbnail? The ones i found are all very very complicated and messy in the source... Thanks, Tintin
21
by: Applebrownbetty | last post by:
Hi, I've run into a problem with IE 6 vs. Mozilla when displaying a completely CSS positioned page, and was wondering if any resident CSS guru might quickly be able to find the problem(s). Thank...
7
by: Joker7 | last post by:
Hi, This is still giving me a big problem !! Maybe if I post the original code here it may be of more help as the above will/is not working. $link = "<a
8
by: Jakej | last post by:
I've been using a javascript in an html file for a banner slider, and it works as desired. But I'd like to use it on more than one page and it would be great if I could transfer the code to a .js...
1
by: Charles Harrison Caudill | last post by:
with tables there is a clean and algorithmic way to organize things, but with css which is, once you get it working, much cleaner, I have to tweak and patch and hope and pray and curse before...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
1
by: jon23d | last post by:
Good afternoon, I am trying to get a pop-up div to position itself relative to the mouse position when a user clicks on a link. The positioning is working fine in every browser except IE where...
13
by: Griff | last post by:
Hi Sorry no screen shots or links...I want to achieve the following visual effect: I want three boxes to appear on screen, all within a parent box (so 4 in total). Concerning the three...
2
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I run a server side script? ----------------------------------------------------------------------- You...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.