0

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?

paul0080
  • 163
  • 1
  • 3
  • 13
  • duplicate of http://stackoverflow.com/questions/7602078/javascripts-window-resizeto-isnt-working – Dmitriy Mar 05 '16 at 09:32
  • @Dmitriy Loskutov How can i resize new windows using javascript. – paul0080 Mar 05 '16 at 09:41
  • Possible duplicate of [Image auto resize to fit div container](http://stackoverflow.com/questions/3029422/image-auto-resize-to-fit-div-container) – MX D Mar 05 '16 at 13:12

0 Answers0