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