I want to create a rectangle inside an HTML page, then write some text on that rectangle. I also need that text to be a hyperlink. This is what I did but it is not working:<
Change
var svg = document.documentElement;
to
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
so that you create a SVG element.
SVG
For the link to be an hyperlink, simply add a href attribute :
href
h.setAttributeNS(null, 'href', 'http://www.google.com');
Demonstration