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