1๐
โ
By default, the canvas size is 300 x 150, so when you set the height or width equal to the default size it gets overridden
So the below setting is of no use:
var canvas = document.createElement('canvas');
canvas.width = 300;
canvas.height = 150;
document.getElementById('width').innerHTML = canvas.getAttribute('width');
document.getElementById('height').innerHTML = canvas.getAttribute('height');
However, if you can set the height or width other than the default one then it should reflect and work in both Edge and Chrome.
var canvas = document.createElement('canvas');
canvas.width = 1020;
canvas.height = 151;
document.getElementById('width').innerHTML = canvas.getAttribute('width');
document.getElementById('height').innerHTML = canvas.getAttribute('height');
Source:stackexchange.com