Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <img id="imgs" style="width:90%;" src="images/mypic.jpg" />
  2. ============================================================
  3.  
  4. <script>
  5.  
  6. $(document).on('pageshow', '#index', function(event) {
  7. resizeimage(awidth,aheight )
  8. });
  9.  
  10. $(window).resize(function() {
  11. resizeimage(awidth,aheight )
  12. });
  13.  
  14.  
  15.  
  16.  
  17. function resizeimage(maxwidth, maxheight){
  18.  
  19. var width = $(imgs).width(); // Current image width
  20. var height = $(imgs).height(); // Current image height
  21.  
  22. // **** this is trace output only
  23. //$(windowwidth).text($(window).width());
  24. //$(windowheight).text($(window).height());
  25. //$(iwidth).text($(imgs).width());
  26. //$(iheight).text($(imgs).height());
  27.  
  28.  
  29. if(parseInt(width, 10) > maxwidth){
  30.  
  31. //$(info).text('bigger'); // trace output
  32. $(imgs).css("width", maxwidth); // dont allow image to resize larger than its actual size
  33. }else
  34. {
  35. //$(info).text('smaller'); // trace output
  36. $(imgs).css("width", "100%"); // allow image to resize below its actual size
  37. }
  38.  
  39. }
  40.  
  41. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement