[Javascript] Image position in the form

Hakan M. hakan at backbase.com
Wed Dec 17 04:01:21 CST 2003


Just saw that I'm using parseInt2, another handy function. parseInt 
returns "NaN" if the value is not a number, my parseInt2 always returns 
a number (0 instead of NaN). Simple but useful.

_________________________________

function parseInt2(sInt) {
	var i = parseInt(sInt);
	if(isNaN(i)) return 0;
	else return i;
}
_________________________________

Hakan M. wrote:

> 
> This is a function I've been working on, it seems to work in 99% of the 
> cases, but I'm still getting a slight offset in some scenarios. The 
> offset seem to occur (no extensive testing yet) when the element is 
> deeply nested in tables and other elements that have "special" 
> padding/margin/offset-values.
> 
> I'm using internal pointer for BROWSER_SCROLL_LEFT and 
> BROWSER_SCROLL_TOP. If you are running Mozilla/IE6 in quirks mode, 
> you'll find these values in document.body.scrollLeft/scrollTop;, and in 
> standards compliant mode, they can be found in 
> document.documentElement.scrollLeft/scrollTop.
> 
> Hope this helps.
> Hakan
> ______________________________________________
> 
> function GetXY(oElement) {
> 
>     var oOrgElm = oElement;
> 
>     var iX=0;
>     var iY=0;
>     var iCount;
>     var oElement2;
>     var oElementOffset = oElement.offsetParent;
> 
>     while(oElement) {
>         oElement2 = oElement.parentNode;
>         if(oElementOffset == oElement) {
>             iX += oElement.offsetLeft;
>             iY += oElement.offsetTop;
>             // Add for borders
>             iY += parseInt2(oElement.style.borderTopWidth);
>             iX += parseInt2(oElement.style.borderLeftWidth);
>             // Add for scrolling
>             iX -= parseInt2(oElement.scrollLeft);
>             iY -= parseInt2(oElement.scrollTop);
>             // Get the next offsetParent
>             oElementOffset = oElementOffset.offsetParent;
>         }
>         else {
>             iX -= parseInt2(oElement.scrollLeft);
>             iY -= parseInt2(oElement.scrollTop);
>         }
> 
>         oElement = oElement2;
>     }
> 
>     iX += parseInt2(BROWSER_SCROLL_LEFT);
>     iY += parseInt2(BROWSER_SCROLL_TOP);
> 
>     oOrgElm.iX = iX;
>     oOrgElm.iY = iY;
> }
> ______________________________________________
> 
> 
> 
> Manchikanti, Rosi Reddy (Cognizant) wrote:
> 
>> Hello,
>>
>> i have one Html page. in that page i have some text and some images 
>> are placed. I want to find the image position in the page.(i mean 
>> co-ordinate position which compatible for both IE and NetScape 
>> Navigator6). u please find the solution for that.
>>
>>
>> Thanks & Regards
>> Rosi Reddy.
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> This e-mail and any files transmitted with it are for the sole use of 
>> the intended recipient(s) and may contain confidential and privileged 
>> information.
>> If you are not the intended recipient, please contact the sender by 
>> reply e-mail and destroy all copies of the original message. Any 
>> unauthorised review, use, disclosure, dissemination, forwarding, 
>> printing or copying of this email or any action taken in reliance on 
>> this e-mail is strictly prohibited and may be unlawful.
>>
>>         Visit us at http://www.cognizant.com
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> .
> 




More information about the Javascript mailing list