cannot focus an <object> (e.g. flash) with javascript

RESOLVED WORKSFORME

Status

()

RESOLVED WORKSFORME
16 years ago
14 years ago

People

(Reporter: ejstock, Unassigned)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

16 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/0.6.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007

In the following HTML, the line:

flash.focus();

causes this error in my Javascript console:

Error: flash.focus is not a function

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>c64</title>
<script type='text/javascript'>
  function focusFlash()
  {
    flash = document.getElementById('c64embed');
    flash.focus();
  }
</script>
</head>
<body bgcolor="#3333cc" onload="focusFlash();">
<!-- body bgcolor="#3333cc" onload="alert('onload');" -->
<!--url's used in the movie-->
<a href="http://www.channelzero.co.nz/64/media/q_bert.zip"></a>
<!--text used in the movie-->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
width="530" height="350" id="c64object" align="middle">

<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="c64.swf" />
<param name="menu" value="false" />
<param name="quality" value="low" />
<param name="bgcolor" value="#3333cc" />
<embed src="c64.swf" menu="false" quality="low" bgcolor="#3333cc" width="530"
height="350" name="c64" id="c64embed" align="middle"
allowScriptAccess="sameDomain" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"/>
</object>
</body>
</html>

Iterating through the properties of the element like so:

   for (var propName in flash)
   {
     output += propName + ", ";
   }
   alert("flash properties: " + output);

indeed shows no such method. How come?


Reproducible: Always

Steps to Reproduce:
1. open mozilla
2. open javascript console
3. hit above page

Actual Results:  
javascript error: focus is not a function

Expected Results:  
flash element (embed tag) should have been given focus
Nothing to do with events.  Why exactly should there be a focus() method there?
 Do you expect that to be present on all <embed>s or just Flash ones?
Assignee: events → general
Component: DOM Events → DOM Level 0
(Reporter)

Comment 2

16 years ago
Why should there be a focus() method there? Well, I'd use for one if there were.
Why not?

All embeds I guess. (BTW, IE provides focus() on <object> tags, not that that in
itself is a reason).
Interesting.  In DOM2 HTML, <select>, <input>, <anchor>, <textarea> have focus()
methods, but <button> and <object> do not.  jst, that seems like an oversight to
me....

Comment 4

15 years ago
HTML 4 Button elements have an onfocus event attribute but not so for HTML 4
Objects.
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:
Firefox:     http://www.mozilla.org/projects/firefox/
Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html
Seamonkey:   http://www.mozilla.org/projects/seamonkey/

Comment 6

14 years ago
*** Bug 289623 has been marked as a duplicate of this bug. ***

Updated

14 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: focus is not a function → cannot focus an <object> (e.g. flash) with javascript
WFM using
Mozilla/5.0 (Windows; U; Windows NT 5.2; ja-JP; rv:1.9a1) Gecko/20051027 Firefox/1.6a1
JS error doesn't occur. Focus() method now exists.
Status: NEW → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → FIXED

Comment 8

14 years ago
WORKSFORME != FIXED. Please resolve as WORKSFORME instead.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Status: REOPENED → RESOLVED
Last Resolved: 14 years ago14 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.