JavaScript Reference/Javascript Properties/src

Материал из Web эксперт
Перейти к: навигация, поиск

"src" Example

    
<html>
<body>
<img id="myImg" src="" alt="" onClick="function1();">
<button onclick="function1();">Click here to load image</button>
<script language="JavaScript">
    function function1() {
        document.all.myImg.src = "yourimage.gif";
    }
</script>
</body>
</html>



"src" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<applet>                        <bgsound>                     |
|                |<embed>                                                       |
|                |<frame>                         <iframe>                      |
|                |<img>                           <input type="image">          |
|                |<script>                        <xml>                         |
+----------------+--------------------------------------------------------------+



"src" Syntax and Note

Note:
Read and write property. 
Specifies the URL of the source of the object.
    
Syntax:
    
document.getElementById("elementID").src = value
document.all.elementID.src = value // IE only