[webkit-dev] How to add a attribute for "object" tag and can be modified by JavaScript

Eric Seidel eric at webkit.org
Thu May 21 07:35:23 PDT 2009


<object> tags use data="" not src="".  Blame HTML 4.
http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3

-eric

2009/5/22 Darin Adler <darin at apple.com>:
> 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
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>


More information about the webkit-dev mailing list