K
krzysztof.murkowski
Hi,
I have problem with JavaScript for gallery of images.
From the overview page with thumbnails, after a click on the small
picture,
the subpage 'slide_show.html' is called, with a number of picture as
parameter
for example: <a href=slide_show.html?nb=2>
(The code is at the end of this post)
The page 'slide_show.html' should display the appropriate picture
and give the possibility to navigate previous/next.
Result: some browsers don't display the first picture. It looks like a
browser
finished to display the picture before it resolved its name.
Some browsers show the first picture ok.
The navigation previous/next works always ok.
What is wrong? I tried to move the code inside the page but it didn't
help.
With the help of document.write I can see, that the parsing of
parameter
and finding the name of the picture was ok, but it wasn't displayd.
Do you have any ideas?
Best regards,
K.
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
NewImg = new Array (
"P0000284.jpg",
"P0000286.jpg",
"P0000287.jpg",
"P0000288.jpg",
"P0000291.jpg"
);
var current = 0;
var len = NewImg.length - 1;
var param = location.search;
param = param.substr(4,param.length);
current = eval(param);
document.write( "location.href: ", location.href, "<BR>" );
document.write( "location.search: ", location.search, "<BR>" );
document.write( "param: ", param, "<BR>" );
document.write( "current: ", current, "<BR>" );
function showImg()
{
document.slideshow.src = NewImg[current];
}
function chgImg(direction)
{
if (document.images)
{
current = current + direction;
if (current > len)
{
current = 0;
}
if (current < 0)
{
current = len;
}
document.slideshow.src = NewImg[current];
}
}
</script>
</HEAD>
<BODY>
<a href="javascript:chgImg(-1)">Previous</a>
<a href="javascript:chgImg(1)">Next</a>
<br><br>
<img src="javascript:showImg()" name="slideshow">
<br><br>
<a href="javascript:chgImg(-1)">Previous</a>
<a href="javascript:chgImg(1)">Next</a>
</BODY>
</HTML>
I have problem with JavaScript for gallery of images.
From the overview page with thumbnails, after a click on the small
picture,
the subpage 'slide_show.html' is called, with a number of picture as
parameter
for example: <a href=slide_show.html?nb=2>
(The code is at the end of this post)
The page 'slide_show.html' should display the appropriate picture
and give the possibility to navigate previous/next.
Result: some browsers don't display the first picture. It looks like a
browser
finished to display the picture before it resolved its name.
Some browsers show the first picture ok.
The navigation previous/next works always ok.
What is wrong? I tried to move the code inside the page but it didn't
help.
With the help of document.write I can see, that the parsing of
parameter
and finding the name of the picture was ok, but it wasn't displayd.
Do you have any ideas?
Best regards,
K.
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
NewImg = new Array (
"P0000284.jpg",
"P0000286.jpg",
"P0000287.jpg",
"P0000288.jpg",
"P0000291.jpg"
);
var current = 0;
var len = NewImg.length - 1;
var param = location.search;
param = param.substr(4,param.length);
current = eval(param);
document.write( "location.href: ", location.href, "<BR>" );
document.write( "location.search: ", location.search, "<BR>" );
document.write( "param: ", param, "<BR>" );
document.write( "current: ", current, "<BR>" );
function showImg()
{
document.slideshow.src = NewImg[current];
}
function chgImg(direction)
{
if (document.images)
{
current = current + direction;
if (current > len)
{
current = 0;
}
if (current < 0)
{
current = len;
}
document.slideshow.src = NewImg[current];
}
}
</script>
</HEAD>
<BODY>
<a href="javascript:chgImg(-1)">Previous</a>
<a href="javascript:chgImg(1)">Next</a>
<br><br>
<img src="javascript:showImg()" name="slideshow">
<br><br>
<a href="javascript:chgImg(-1)">Previous</a>
<a href="javascript:chgImg(1)">Next</a>
</BODY>
</HTML>