Latest web development tutorials

HTML DOM Embed src attribute

Embed Object Reference Embed the object

Examples

Returns the embedded file URL:

var x = document.getElementById("myEmbed").src;
x The output is:
http://www.w3cschool.cc/jsref/helloworld.swf

try it"

Definition and Usage

src attribute is used to set or return the value embed src attribute of the element.

src attribute describes the embedded files external address (URL).


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the src attribute.


grammar

Back src attribute:

embedObject .src

Setting the src attribute:

embedObject .src= URL

Property Value

描述
URL 描述了嵌入文件的外部地址 (URL)

可能值:
  • 绝对URL地址 - 指向另外一个站点的地址 (如: src="http://www.example.com/hello.swf")
  • 相对 URL 地址 - 指向站内地址 (如:src="hello.swf")

technical details

return value: String representing the URL embedded in the file, return entity URL, contains the protocol part (http: //)


Related Pages

HTML Reference Manual: HTML <the embed> the src attribute


Embed Object Reference Embed the object