forked from cowboy/jquery-misc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
141 lines (106 loc) · 3.53 KB
/
index.php
File metadata and controls
141 lines (106 loc) · 3.53 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?PHP
include "../index.php";
$shell['title3'] = "loadAdScript";
$shell['h2'] = 'Keep ad scripts that use document.write from breaking your stuff!';
// ========================================================================== //
// SCRIPT
// ========================================================================== //
ob_start();
?>
$(function(){
// a.js simply calls document.write a few times. It's not great, but it's not
// the end of the world.
$('#a').loadAdScript( 'a.js', function(){
$(this).show(); // When the ad script has loaded, show the ad.
});
// b.js calls document.write and loads another external script that also calls
// document.write. It's starting to get ugly, but that's what third party ad
// networks are all about!
$('#b').loadAdScript( 'b.js', function(){
$(this).show(); // When the ad script has loaded, show the ad.
});
// c.js calls document.write and loads multiple other external scripts that
// also call document.write and load other external scripts. Look out, because
// there's a "web 1.0 document write" party in your page, and everyone's invited!
$('#c').loadAdScript( 'c.js', function(){
$(this).show(); // When the ad script has loaded, show the ad.
});
});
<?
$shell['script'] = ob_get_contents();
ob_end_clean();
// ========================================================================== //
// HTML HEAD ADDITIONAL
// ========================================================================== //
ob_start();
?>
<script type="text/javascript" src="../../shared/jquery.ba-jqmq.js"></script>
<script type="text/javascript" src="../../jquery.ba-loadadscript.js"></script>
<script type="text/javascript" language="javascript">
<?= $shell['script']; ?>
$(function(){
// Syntax highlighter.
SyntaxHighlighter.highlight();
});
</script>
<style type="text/css" title="text/css">
/*
bg: #FDEBDC
bg1: #FFD6AF
bg2: #FFAB59
orange: #FF7F00
brown: #913D00
lt. brown: #C4884F
*/
#page {
width: 700px;
}
.ad {
display: none;
width: 468px;
height: 60px;
border: 1px solid #000;
margin-bottom: 1em;
}
.ad a {
color: #aaa;
}
.ad a:hover {
color: #FF7F00;
}
</style>
<?
$shell['html_head'] = ob_get_contents();
ob_end_clean();
// ========================================================================== //
// HTML BODY
// ========================================================================== //
ob_start();
?>
<?= $shell['donate'] ?>
<p>
With <a href="http://benalman.com/projects/jquery-misc-plugins/#loadadscript">jQuery loadAdScript</a> you can load third party ad network scripts that use <code>document.write</code> into specific containers. The only downside is that the ads will load serially.. but that's necessary to keep them from stepping on each others' toes. And the upside is that your site isn't completely borked!
</p>
<p>
Requires the <a href="http://benalman.com/projects/jquery-message-queuing-plugin/">jQuery Message Queueing</a> plugin.
</p>
<h3>Sample ads</h3>
<p>
In this example, the ads are hidden by default, and are only shown when their ad script has finished executing.
</p>
<div id="a" class="ad"></div>
<div id="b" class="ad"></div>
<div id="c" class="ad"></div>
<h3>The code</h3>
<div class="clear"></div>
<pre class="brush:js">
<?= htmlspecialchars( $shell['script'] ); ?>
</pre>
<?
$shell['html_body'] = ob_get_contents();
ob_end_clean();
// ========================================================================== //
// DRAW SHELL
// ========================================================================== //
draw_shell();
?>