Properties


SRC Attribute | src Property

Sets or retrieves a URL to be loaded by the object.

Syntax

HTML<ELEMENT SRC = sURL... >
Scripting[ sURL = ] object.src

Possible Values

sURLString that specifies or receives the URL.

The property is read/write. The property has no default value.

DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are not supported in IE8 mode. For more information, see About Dynamic Properties.

Remarks

 New for Windows Internet Explorer 8 Internet Explorer 8 or later. In IE8 mode, the value of the SRC attribute of the frame and iframe elements depends on the context of the reference to the attribute. When read as a Document Object Model (DOM) attribute, SRC returns an absolute URL. The value specified by the page author is returned when SRC is read as a content attribute, when the page is displayed in an earlier document compatibility mode, or when the page is viewed with an earlier version of the browser. For more information, see Attribute Differences in Internet Explorer 8.

Example

This example uses the src property to change the src attribute of an iframe.


function changeFrame(){
  alert (document.all.iframe1.src);
  document.all.iframe1.src="http://www.microsoft.com/";
  alert (document.all.iframe1.src);
}

Standards Information

This property is defined in HTML 4.0 World Wide Web link and is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 World Wide Web link.

Applies To

APPLET, EMBED, FRAME, IFRAME, XML, HTMLEmbedElement Constructor, HTMLFrameElement Constructor, HTMLIFrameElement Constructor
Tags :


Community Content

IE7 and local image preview before upload
How to preview a local image before uploading it, IE6; what about IE7?

<script>

ie4up=true;
function Picture3Image()
{ if(document.all.item("TFileID3") !=null){
if (ie4up){document.all.item("Picture3").src= document.all.item("TFileID3").value; }
else {document.getElementById("Picture3").src= document.getElementById("TFileID3").value;
}
}else{alert("wwwwwww");}
}

</script>

<input size="37" style=" WIDTH: 360px" id="TFileID3" name="TFileID3" type="file" onChange="javascript:Picture3Image();" >
&nbsp; </nobr> <img id="Picture3" src="Images/trans.gif" border="0" width="70px" height="91px">

Tags :

SpodMod
error, incompatible with w3c
src doesn't actually check the current source of an object. When some user script changes the source, IE takes note of it. When you request the source IE checks what the script changed it to rather than checking the current source. If you clicked a link within the page in an iframe and therefore changed the iframes source. src would return the address of the original page instead.
Tags : error

SpodMod
error, incompatable with w3c
src doesn't actually check the current source of an object. When some user script changes the source, IE takes note of it. When you request the source IE checks what the script changed it to rather than checking the current source. If you clicked a link within the page in an iframe and therefore changed the iframes source. src would return the address of the original page instead.
Tags : error

Page view tracker