By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,992 Members | 967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,992 IT Pros & Developers. It's quick & easy.

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

P: n/a
gsb
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
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
DU
gsb wrote:
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.

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
Any help will be appreciated.

Thanks

gsb


Jul 20 '05 #2

P: n/a
gsb
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
Jul 20 '05 #3

P: n/a
DU
gsb wrote:
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.

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.

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

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.
Any thoughts?

Thanks for you time and help.

gsb


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
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.