Connecting Tech Pros Worldwide Help | Site Map

HOW TO: Find the Top & Left window offset of an embed'ed [Flash] object.

gsb
Guest
 
Posts: n/a
#1: Jul 20 '05
I'd like to get the offset coordinates, top & left, of an embedded Flash
movie.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.ca
b#version=7,0,14,0"
id="tabMenu" width="720" height="420">
<param name="movie" value="tabMenu.swf">
<param name="menu" value="false">
<param name="quality" value="best">
<param name="wmode" value="opaque">
<param name="base" value="file://C:/WINDOWS/Desktop/031122a/">
<param name="bgcolor" value="#FFFFFF">
<param name="allowScriptAccess" value="sameDomain">
<embed id="tabMenu" name="tabMenu" src="tabMenu.swf"
menu="false" quality="best" wmode="opaque"
base="file://C:/WINDOWS/Desktop/031122a/" bgcolor="#FFFFFF"
swLiveConnect="true" allowScriptAccess="sameDomain"
width="720" height="420"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
</object>

I'm using Netscape 7.1.

document.tabmenu.offsetLeft and document.tabmenu.offsetTop don't seem to do
it correctly.

Any help will be appreciated.

Thanks

gsb


DU
Guest
 
Posts: n/a
#2: Jul 20 '05

re: HOW TO: Find the Top & Left window offset of an embed'ed [Flash] object.


gsb wrote:[color=blue]
> I'd like to get the offset coordinates, top & left, of an embedded Flash
> movie.
>
> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
>
> codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.ca
> b#version=7,0,14,0"
> id="tabMenu" width="720" height="420">
> <param name="movie" value="tabMenu.swf">
> <param name="menu" value="false">
> <param name="quality" value="best">
> <param name="wmode" value="opaque">
> <param name="base" value="file://C:/WINDOWS/Desktop/031122a/">
> <param name="bgcolor" value="#FFFFFF">
> <param name="allowScriptAccess" value="sameDomain">
> <embed id="tabMenu" name="tabMenu" src="tabMenu.swf"
> menu="false" quality="best" wmode="opaque"
> base="file://C:/WINDOWS/Desktop/031122a/" bgcolor="#FFFFFF"
> swLiveConnect="true" allowScriptAccess="sameDomain"
> width="720" height="420"
> type="application/x-shockwave-flash"
> pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
> </object>
>
> I'm using Netscape 7.1.
>
> document.tabmenu.offsetLeft and document.tabmenu.offsetTop don't seem to do
> it correctly.
>[/color]

document.getElementById("tabMenu").offsetLeft
and
document.getElementById("tabMenu").offsetTop
will give the offset values relative to its offsetParent, not necessarly
relative to the document or the browser viewport. offset[Left/Top] is
always relative to the offsetParent node, the node which acts like the
positional context of inner nodes ("offsetParent node: closest
positioned containing element within the DOM node containment hierarchy").

To reference an element, use document.getElementById or another DOM 1
method.

I recommend you read these:

Using Web Standards in Your Web Pages:
Accessing Elements with the DOM
http://www.mozilla.org/docs/web-deve...tml#dom_access

Updating DHTML Web Pages for next generation browsers
http://devedge.netscape.com/viewsour...tml-web-pages/


DU
[color=blue]
> Any help will be appreciated.
>
> Thanks
>
> gsb
>
>[/color]

gsb
Guest
 
Posts: n/a
#3: Jul 20 '05

re: HOW TO: Find the Top & Left window offset of an embed'ed [Flash] object.


Basically, that is what I was trying:

function getOffsetLeft(o) { var ol=o.offsetLeft;
while((o=o.offsetParent)!=null) { ol+=o.offsetLeft;} return ol }
function getOffsetTop (o) { var ot=o.offsetTop;
while((o=o.offsetParent)!=null) { ot+=o.offsetTop;} return ot }
function libGetLoc(o) { var c=new
Object();c.x=getOffsetLeft(o);c.y=getOffsetTop(o); return c }

loc = libGetLoc( document.getElementById("tabMenu") );

In Netscape it gives me a wrong 'Top' number, way off. IE is correct.

If I surround all with a DIV tag and get the location of the that tag, both
are correct.

Any thoughts?

Thanks for you time and help.

gsb


DU
Guest
 
Posts: n/a
#4: Jul 20 '05

re: HOW TO: Find the Top & Left window offset of an embed'ed [Flash] object.


gsb wrote:[color=blue]
> Basically, that is what I was trying:
>
> function getOffsetLeft(o) { var ol=o.offsetLeft;
> while((o=o.offsetParent)!=null) { ol+=o.offsetLeft;} return ol }
> function getOffsetTop (o) { var ot=o.offsetTop;
> while((o=o.offsetParent)!=null) { ot+=o.offsetTop;} return ot }
> function libGetLoc(o) { var c=new
> Object();c.x=getOffsetLeft(o);c.y=getOffsetTop(o); return c }
>
> loc = libGetLoc( document.getElementById("tabMenu") );
>
> In Netscape it gives me a wrong 'Top' number, way off. IE is correct.[/color]


I don't see how you call your function. I don't see any of your markup
code. No specifics. No url.
"way off" could mean 50px, could mean 500px or could mean 1000px. Here,
I don't even have an idea of magnitude.
[color=blue]
>
> If I surround all with a DIV tag and get the location of the that tag, both
> are correct.
>[/color]

I don't see any of what you say in your posted messages. So I can not
follow you or reproduce what you see. An url would have been helpful.
[color=blue]
> Any thoughts?
>
> Thanks for you time and help.
>
> gsb
>
>[/color]

Is your markup code valid, validated?
Is your code triggering backward compatible rendering mode in MSIE 6 for
windows?
In your initial post, you have 2 distinct elements (object and embed)
with the same id="tabMenu"; now, this is a validation error...
"(...) must be unique in a document."
http://www.w3.org/TR/html401/struct/global.html#adef-id
most likely having consequences on your script function correct behavior.
It's very difficult to recommend anything more without being able to
examine the whole code.

DU


Closed Thread


Similar JavaScript / Ajax / DHTML bytes