Change the name of a URL field:
document.getElementById("myURL").name = "newNameValue";
Click the buttons to display and change the value of the name attribute of the URL field.
elements with type="url" are not supported in Safari.
<!DOCTYPE html> <html> <body> <p id="demo"></p> Homepage: <input type="url" id="myURL" name="website"> <button onclick="display()">Display name</button> <button onclick="change()">Change name</button> <script> function display() { var x = document.getElementById("myURL").name; document.getElementById("demo").innerHTML = "The name of the URL field is: " + x; } function change() {// w w w . j a v a2 s . co m var x = document.getElementById("myURL").name = "newNameValue"; document.getElementById("demo").innerHTML = "The name was changed to: " + x; } </script> </body> </html>