[webkit-dev] How to add a attribute for "object" tag and can be modified by JavaScript
Darin Adler
darin at apple.com
Thu May 21 07:25:19 PDT 2009
On May 21, 2009, at 7:12 AM, naixuan guan wrote:
> when I open the HTML page like follow:
>
> <OBJECT id="StormPlayer" width = 800 height = 400 src = "111"></
> OBJECT>
> <script language="JavaScript">
> alert(document.StormPlayer.src);
> </Script>
>
> the warning message will show "undefined". why?
Because not every HTML attribute has a corresponding JavaScript
property.
But alert(document.getElementById("StormPlayer").getAttribute("src"))
should work.
> can I add the "src" attribute to "object" tag and can be modified by
> JavaScript?
Yes, by calling objectElement.setAttribute("src", newSourceValue).
-- Darin
More information about the webkit-dev
mailing list