Create a Map Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Map


You can create a <map> element by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<img src="" width="100" height="100" usemap="#myMap">

<button onclick="myFunction()">create an IMAGE-MAP and an AREA element with a link to ""</button>

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

function myFunction() {/*from w  w w.  j  av  a2 s .c  o  m*/
    var x = document.createElement("MAP");
    x.setAttribute("id", "myMap");
    x.setAttribute("name", "myMap");

    var y = document.createElement("AREA");
    y.setAttribute("href", "");
    y.setAttribute("shape", "circle");
    y.setAttribute("coords", "120,50,10");

    document.getElementById("demo").innerHTML = "The MAP was created.";


Related Tutorials