Javascript DOM HTML Link sizes Property get

Introduction

Return the size of the linked icon:

var x = document.getElementById("myLink").sizes;

Click button to return the value of the sizes attribute of the link element.

View in separate window

<!DOCTYPE html>
<html>
<head>
<link id="myLink" rel="icon" href="image1.png" type="image/gif" sizes="100x100">
</head>/*w  ww  . ja  v a 2s. co  m*/
<body>

<h2>Hello world!</h2>
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
  var x = document.getElementById("myLink").sizes;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The sizes property returns the value of the sizes attribute of the linked resource.

The sizes attribute specifies the sizes of icon for visual media, and is only used if rel="icon".

The sizes attribute is currently not supported in any of the major browsers.

This property is read-only.

Return Value: The size of the icon



PreviousNext

Related