All Tech Tips

SRC Attribute | src Property

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

Syntax

HTML<ELEMENT SRC = sURL... >
Scriptingobject.src [ = sURL ]

Possible Values

sURLString that specifies or receives the URL.

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

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. .

Examples

This example uses the src property to change the image's SRC attribute.

<BODY onmousedown="oImage.src='sphere.jpg'" 
    onmouseup="oImage.src='cone.jpg'">
:
<IMG ID=oImage SRC="cone.jpeg">

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  and is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .

Applies To

APPLET, EMBED, FRAME, IFRAME, IMG, INPUT type=image, XML


Copyright © 2006 alltechtips.com. All rights reserved.

This website and the materials and information you find on this website are provided "as is", without warranty of any kind, either express or implied, including without limitation any warranty for information, services, or products provided through or in connection with the service and any implied warranties of merchantability, fitness for a particular purpose, expectation of privacy or non-infringement.