iframe2.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title>jScrollPane - alternative iframe demo</title>
  6. <!-- styles specific to demo site -->
  7. <link type="text/css" href="style/demo.css" rel="stylesheet" media="all" />
  8. <!-- styles needed by jScrollPane - include in your own sites -->
  9. <link type="text/css" href="style/jquery.jscrollpane.css" rel="stylesheet" media="all" />
  10. <style type="text/css" id="page-css">
  11. /* Styles specific to this particular page */
  12. .iframe-holder {
  13. width: 100%;
  14. height: 200px;
  15. overflow: auto;
  16. }
  17. iframe
  18. {
  19. border: 0;
  20. width: 100%;
  21. height: 100%;
  22. }
  23. </style>
  24. <!-- latest jQuery direct from google's CDN -->
  25. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  26. <!-- the mousewheel plugin -->
  27. <script type="text/javascript" src="script/jquery.mousewheel.js"></script>
  28. <!-- the jScrollPane script -->
  29. <script type="text/javascript" src="script/jquery.jscrollpane.min.js"></script>
  30. <!-- scripts specific to this demo site -->
  31. <script type="text/javascript" src="script/demo.js"></script>
  32. <script type="text/javascript" id="sourcecode">
  33. $(function()
  34. {
  35. $('iframe').bind(
  36. 'load.jsp',
  37. function()
  38. {
  39. var doc = this.contentDocument || this.contentWindow.document;
  40. var jDoc = $(doc);
  41. //jDoc = $('body', doc);
  42. var frame = $(this);
  43. var destWidth = jDoc.width();
  44. var destHeight = jDoc.height();
  45. // Need to unbind the load event otherwise it is triggered again
  46. // when jScrollPane wraps the iframe which results in it being removed
  47. // from the document and added again.
  48. frame.unbind('load.jsp');
  49. if (destWidth > frame.width()) {
  50. // to allow for the scrollbar...
  51. // Should be possible more cleanly though
  52. destWidth += 16;
  53. }
  54. if (destHeight > frame.height()) {
  55. // to allow for the scrollbar...
  56. // Should be possible more cleanly though
  57. destHeight += 16;
  58. }
  59. frame.width(destWidth);
  60. frame.height(destHeight);
  61. frame.parent().jScrollPane();
  62. }
  63. );
  64. }
  65. );
  66. </script>
  67. </head>
  68. <body>
  69. <div id="top-nav">
  70. <img src="image/logo.png" width="196" height="69" alt="jScrollPane">
  71. <ul>
  72. <li><a href="index.html">Home</a></li>
  73. <li><a href="index.html#examples">Examples</a></li>
  74. <li><a href="index.html#themes">Themes</a></li>
  75. <li><a href="index.html#usage">How to use</a></li>
  76. <li><a href="faqs.html">FAQs</a></li>
  77. <li><a href="known_issues.html">Known issues</a></li>
  78. <li><a href="index.html#support">Support</a></li>
  79. <li><a href="index.html#download">Download</a></li>
  80. </ul>
  81. </div>
  82. <div id="container">
  83. <h1>jScrollPane - alternative approach to implement jScrollPane with iframes</h1>
  84. <p>
  85. This demonstration shows a different approach to <a href="iframe.html">the first iframe demo</a> for
  86. styling the scrollbars associated with an iframe. This approach requires no special code inside the
  87. iframe content pages (e.g. <a href="iframe_content3.html">iframe_content3.html</a> and
  88. <a href="iframe_content4.html">iframe_content4.html</a>) and instead relies on the script in the hosting
  89. page (this page).
  90. </p>
  91. <p>
  92. This approach has some shortcomings though. The mousewheel doesn't work and the calculation of the width
  93. and height seems a little off...
  94. </p>
  95. <h2>Vertical only</h2>
  96. <div class="iframe-holder">
  97. <iframe src="iframe_content3.html"></iframe>
  98. </div>
  99. <h2>Both</h2>
  100. <div class="iframe-holder">
  101. <iframe src="iframe_content4.html"></iframe>
  102. </div>
  103. <h2>Page javascript</h2>
  104. <div id="sourcecode-display">
  105. <p>The contents of this div will be replaced by the javascript added to this page</p>
  106. </div>
  107. <h2>Page CSS</h2>
  108. <div id="css-display">
  109. <p>The contents of this div will be replaced by the CSS added to this page</p>
  110. </div>
  111. </div>
  112. </body>
  113. </html>