Get Script Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Script


The Script object represents an HTML <script> element.

You can access a <script> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<script id="myScript" src="src.js"></script>

<button onclick="myFunction()">get the URL of the external script file</button>

<p id="demo"></p>

function myFunction() {//from   www .ja  v  a  2 s.c o  m
    var x = document.getElementById("myScript").src;
    document.getElementById("demo").innerHTML = x;


Related Tutorials