Javascript Fotoshow
Ik heb weinig verstand van javascript, waarom werkt dit script niet goed in firefox, hij werkt wel goed in ie ?
Code (php)
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
142
143
144
145
146
147
148
149
150
151
152
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
142
143
144
145
146
147
148
149
150
151
152
<script language=\"JavaScript\">
<!-- Beginning of JavaScript -
// Vul hieronder de namen ( met doel eventueel ) van de plaatjes in.. je kunt er net zoveel toevoegen als je wilt
var imgurl=new Array(";
if (!empty($fotos))
{
print "$fotos,$fotoskamer )";
}
else
{
print "$fotoskamer)";
}
echo "
// Afstand van de slideshow linker kantlijn
var x_finalpos=220
// Asftand slideshow vanaf de top
var y_finalpos=160
// stilstaan van de plaatjes in seconden
var standstill=5
// verander hieronder niets meer
var x_slices=6
var y_slices=4
var imgpreload=new Array()
for (i=0;i<=imgurl.length-1;i++) {
imgpreload[i]=new Image()
imgpreload[i].src=imgurl[i]
}
var imgheight
var imgwidth
var screenheight
var screenwidth
var x_step=new Array()
var y_step=new Array()
var x_randompos=0
var y_randompos=0
var i_loop=0
var max_loop=20
var i_image=0
var width_slice
var height_slice
var cliptop=0
var clipbottom=height_slice
var clipleft=0
var clipright=width_slice
var spancounter=0
var pause=10
standstill=1000*standstill
function initiate() {
screenheight=document.body.clientHeight-imgheight-30
screenwidth=document.body.clientWidth-imgwidth-30
width_slice=Math.floor(imgwidth/x_slices)
height_slice=Math.floor(imgheight/y_slices)
cliptop=0
clipbottom=height_slice
clipleft=0
clipright=width_slice
i_loop=0
spancounter=0
if (document.all) {
for (i=0;i<=y_slices-1;i++) {
for (ii=0;ii<=x_slices-1;ii++) {
var thisspan=eval(\"document.all.span\"+spancounter+\".style\")
x_randompos=Math.ceil(screenwidth*Math.random())
y_randompos=Math.ceil(screenheight*Math.random())
thisspan.posLeft=x_randompos
thisspan.posTop=y_randompos
thisspan.clip =\"rect(\"+cliptop+\" \"+clipright+\" \"+clipbottom+\" \"+clipleft+\")\"
clipleft+=width_slice
clipright+=width_slice
spancounter++
}
clipleft=0
clipright=width_slice
cliptop+=height_slice
clipbottom+=height_slice
}
}
explode_IE()
}
function changeimage() {
spancounter=0
for (i=0;i<=y_slices-1;i++) {
for (ii=0;ii<=x_slices-1;ii++) {
var thisspan=eval(\"document.all.span\"+spancounter+\".style\")
thisspan.posLeft=-5000
thisspan.posTop=-5000
spancounter++
}
}
spancounter=0
if (i_image>imgurl.length-1) {i_image=0}
for (i=0;i<=y_slices-1;i++) {
for (ii=0;ii<=x_slices-1;ii++) {
var thisinnerspan=eval(\"span\"+spancounter)
thisinnerspan.innerHTML=\"<img src='\"+imgurl[i_image]+\"'>\"
spancounter++
}
}
imgwidth=document.all.span0.offsetWidth
imgheight=document.all.span0.offsetHeight
i_image++
initiate()
}
function explode_IE() {
spancounter=0
if (i_loop<=max_loop-1) {
for (i=0;i<=y_slices-1;i++) {
for (ii=0;ii<=x_slices-1;ii++) {
var thisspan=eval(\"document.all.span\"+spancounter+\".style\")
x_step[spancounter]=(x_finalpos-thisspan.posLeft)/(max_loop-i_loop)
y_step[spancounter]=(y_finalpos-thisspan.posTop)/(max_loop-i_loop)
thisspan.posLeft+=x_step[spancounter]
thisspan.posTop+=y_step[spancounter]
spancounter++
}
}
i_loop++
var timer=setTimeout(\"explode_IE()\",pause)
}
else {
spancounter=0
clearTimeout(timer)
var timer=setTimeout(\"changeimage()\",standstill)
}
}
if (document.all) {
for (i=0;i<=y_slices-1;i++) {
for (ii=0;ii<=x_slices-1;ii++) {
document.write(\"<span id='span\"+spancounter+\"' style='position:absolute;left:-5000px'></span>\")
spancounter++
}
}
spancounter=0
}
if (document.all) {window.onload=changeimage}
// - End of JavaScript - -->
</script>
";
<!-- Beginning of JavaScript -
// Vul hieronder de namen ( met doel eventueel ) van de plaatjes in.. je kunt er net zoveel toevoegen als je wilt
var imgurl=new Array(";
if (!empty($fotos))
{
print "$fotos,$fotoskamer )";
}
else
{
print "$fotoskamer)";
}
echo "
// Afstand van de slideshow linker kantlijn
var x_finalpos=220
// Asftand slideshow vanaf de top
var y_finalpos=160
// stilstaan van de plaatjes in seconden
var standstill=5
// verander hieronder niets meer
var x_slices=6
var y_slices=4
var imgpreload=new Array()
for (i=0;i<=imgurl.length-1;i++) {
imgpreload[i]=new Image()
imgpreload[i].src=imgurl[i]
}
var imgheight
var imgwidth
var screenheight
var screenwidth
var x_step=new Array()
var y_step=new Array()
var x_randompos=0
var y_randompos=0
var i_loop=0
var max_loop=20
var i_image=0
var width_slice
var height_slice
var cliptop=0
var clipbottom=height_slice
var clipleft=0
var clipright=width_slice
var spancounter=0
var pause=10
standstill=1000*standstill
function initiate() {
screenheight=document.body.clientHeight-imgheight-30
screenwidth=document.body.clientWidth-imgwidth-30
width_slice=Math.floor(imgwidth/x_slices)
height_slice=Math.floor(imgheight/y_slices)
cliptop=0
clipbottom=height_slice
clipleft=0
clipright=width_slice
i_loop=0
spancounter=0
if (document.all) {
for (i=0;i<=y_slices-1;i++) {
for (ii=0;ii<=x_slices-1;ii++) {
var thisspan=eval(\"document.all.span\"+spancounter+\".style\")
x_randompos=Math.ceil(screenwidth*Math.random())
y_randompos=Math.ceil(screenheight*Math.random())
thisspan.posLeft=x_randompos
thisspan.posTop=y_randompos
thisspan.clip =\"rect(\"+cliptop+\" \"+clipright+\" \"+clipbottom+\" \"+clipleft+\")\"
clipleft+=width_slice
clipright+=width_slice
spancounter++
}
clipleft=0
clipright=width_slice
cliptop+=height_slice
clipbottom+=height_slice
}
}
explode_IE()
}
function changeimage() {
spancounter=0
for (i=0;i<=y_slices-1;i++) {
for (ii=0;ii<=x_slices-1;ii++) {
var thisspan=eval(\"document.all.span\"+spancounter+\".style\")
thisspan.posLeft=-5000
thisspan.posTop=-5000
spancounter++
}
}
spancounter=0
if (i_image>imgurl.length-1) {i_image=0}
for (i=0;i<=y_slices-1;i++) {
for (ii=0;ii<=x_slices-1;ii++) {
var thisinnerspan=eval(\"span\"+spancounter)
thisinnerspan.innerHTML=\"<img src='\"+imgurl[i_image]+\"'>\"
spancounter++
}
}
imgwidth=document.all.span0.offsetWidth
imgheight=document.all.span0.offsetHeight
i_image++
initiate()
}
function explode_IE() {
spancounter=0
if (i_loop<=max_loop-1) {
for (i=0;i<=y_slices-1;i++) {
for (ii=0;ii<=x_slices-1;ii++) {
var thisspan=eval(\"document.all.span\"+spancounter+\".style\")
x_step[spancounter]=(x_finalpos-thisspan.posLeft)/(max_loop-i_loop)
y_step[spancounter]=(y_finalpos-thisspan.posTop)/(max_loop-i_loop)
thisspan.posLeft+=x_step[spancounter]
thisspan.posTop+=y_step[spancounter]
spancounter++
}
}
i_loop++
var timer=setTimeout(\"explode_IE()\",pause)
}
else {
spancounter=0
clearTimeout(timer)
var timer=setTimeout(\"changeimage()\",standstill)
}
}
if (document.all) {
for (i=0;i<=y_slices-1;i++) {
for (ii=0;ii<=x_slices-1;ii++) {
document.write(\"<span id='span\"+spancounter+\"' style='position:absolute;left:-5000px'></span>\")
spancounter++
}
}
spancounter=0
}
if (document.all) {window.onload=changeimage}
// - End of JavaScript - -->
</script>
";
Alvast bedankt!
Ik zie PHP en JavaScript door elkaar?
Kan dat niet ? Het werkt in ie ik denk dus dat dat ook in firefox moet kunnen.
Of is dat gewoon niet gebruikelijk en werkt het niet in firefox?
Herman
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
if(!empty($fotos)){
$defoto = $fotos.",".$fotoskamer;
}else{
$defoto = $fotoskamer;
}
?>
<script language=\"JavaScript\">
<!-- Beginning of JavaScript -
// Vul hieronder de namen ( met doel eventueel ) van de plaatjes in.. je kunt er net zoveel toevoegen als je wilt
var imgurl=new Array("<?php echo $defoto; ?>")
// Afstand van de slideshow linker kantlijn
var x_finalpos=220
//vervolg van je script
-->
</script>
if(!empty($fotos)){
$defoto = $fotos.",".$fotoskamer;
}else{
$defoto = $fotoskamer;
}
?>
<script language=\"JavaScript\">
<!-- Beginning of JavaScript -
// Vul hieronder de namen ( met doel eventueel ) van de plaatjes in.. je kunt er net zoveel toevoegen als je wilt
var imgurl=new Array("<?php echo $defoto; ?>")
// Afstand van de slideshow linker kantlijn
var x_finalpos=220
//vervolg van je script
-->
</script>