I want to resize the window to fit image size when using window.open to open a new window.
Html code
<!DOCTYPE html>
<html>
<body>
<a href="#" onclick="window.open ('showimg.php', 'newwindow', 'toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');">go <a/>
</body>
</html>
showimg.php
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<style>
* {
padding: 0;
margin: 0;
border: 0;
outline: 0;
}
</style>
<script type="text/javascript" language="JavaScript">
$(document).ready(function() {
var contentWidth = document.getElementById("#pic").offsetWidth;
var contentHeight = document.getElementById("#pic").offsetHeight;
window.resizeTo(contentWidth,contentHeight);
});
</script>
</head>
<body>
<img id="pic" name="pic" src="../css/discount/uniqlo_coupon.jpg" >
</body>
</html>
But the showimg.php cannot resize via javascript.
How can i do it?