Posted By

DaveChild on 02/04/09


Tagged

javascript


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


JavaScript Apply Max-Width (in Pixels) in IE


Published in: JavaScript 






URL: http://www.addedbytes.com

Expand | Embed | Plain Text
  1. var maxWidth = '750'; // Max width of area to be resized
  2. var content_area_id = ''; // ID of the element to be resized
  3.  
  4. var resizeTimeout = null;
  5.  
  6. function fixWidth() {
  7. var visibleArea = document.documentElement.clientWidth;
  8. if (visibleArea > maxWidth) {
  9. document.getElementById(content_area_id).style.width = maxWidth;
  10. } else {
  11. document.getElementById(content_area_id).style.width = visibleArea;
  12. }
  13. }
  14.  
  15. function addLoadEvent(func) {
  16. var oldonload = window.onload;
  17. if (typeof window.onload != 'function') {
  18. window.onload = func;
  19. } else {
  20. window.onload = function() {
  21. if (oldonload) {
  22. oldonload();
  23. }
  24. func();
  25. }
  26. }
  27. }
  28.  
  29. window.onresize=function(){
  30. if (resizeTimeout) {
  31. window.clearInterval(resizeTimeout);
  32. }
  33. resizeTimeout = setTimeout(fixWidth, 500);
  34. }
  35.  
  36. addLoadEvent(fixWidth);

Report this snippet 

You need to login to post a comment.