Jeg har lavet et simpelt billedgalleri, som viser alle billeder i
en folder. For at Thumbnail siderne skal loade hurtigt har jeg
lavet mindre udgaver af billederne til Thumbnailsiden. Disse
sider loader da også rimeligt hurtigt.
Problemet er PopUp vinduet med de store billeder. Det tager en
krig at loade det - selv om billederne er mellem 15 og 38 kb.
Hvad kan der være galt??
Eksemplet kan ses her på denne ikke færdigudviklede hjemmeside:
http://www.clearweb.dk/sport/sport_fotoalbum.asp
Koden til PopUp vinduet:
<html>
<head>
<title>Show Picture</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Alan Chu -->
<!-- Web Site:
http://homepage.hkpeoples.net -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!!
http://javascript.internet.com -->
<!-- Begin
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == "Netscape") ? 1 : 0;
isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
}
function fitWindowSize() {
if (isNav4) {
window.innerWidth = document.layers[0].document.images[0].width;
window.innerHeight =
document.layers[0].document.images[0].height;
}
if (isIE4) {
window.resizeTo(800, 600);
width = (800 - (document.body.clientWidth -
document.images[0].width)) + 25;
height = (600 - (document.body.clientHeight -
document.images[0].height)) + 55;
window.resizeTo(width, height);
}
}
// End -->
</script>
<link href="../main.css" rel="stylesheet" type="text/css">
</head>
<BODY onLoad="fitWindowSize()">
<center>
<%
ShowPic = request("ShowPic")
ShowPic = Replace(ShowPic, " ", "%20")
Response.Write "<img src='Foto/Stor/" & ShowPic & "'
border=1><BR>"
response.write "<font size='2'><a href='JavaScript:onClick=
window.close()'><font color='#000000'>Luk
vinduet</font></A></font>"
%>
</center>
</body>
</html>
KODEN TIL tHUMBNAILSIDEN (øverste del):
<%
' PhotoAlbum
Dim CurFile, PopFileShowSub, ShowPic, PictureNo
Dim strPathInfo, strPhysicalPath
Dim intTotPics, intPicsPerRow, intPicsPerPage, intTotPages,
intPage, strPicArray()
intPicsPerRow = 4
intPicsPerPage = 8
intPage = CInt(Request.QueryString("Page"))
If intPage = 0 Then
intPage = 1
End If
CurFile = "sport_fotoalbum.asp"
PopFile = "ShowPicture.asp"
%>
<script language="JavaScript">
<!--
function jumppage(sel)
{
var i = sel.selectedIndex
self.location.href = sel.options[i].value
}
// -->
</script>
<script language="JavaScript">
<!-- hide from JavaScript-challenged browsers
function openGalleryWindow(url) {
if (document.all)
var xMax = screen.width, yMax = screen.height;
else
if (document.layers)
var xMax = window.outerWidth, yMax = window.outerHeight;
else
var xMax = 800, yMax=600;
var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;
var xOffset = 100, yOffset = 100;
popupWin =
window.open(url,'new_page','width=700,height=535,screenX='+xOffse
t+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollba
rs=auto,toolbars=no,menubar=no,resizable=yes')
}
// done hiding -->
</script>
KODEN TIL tHUMBNAILSIDEN (nederste del):
<td align="center" width="25%">
<form action=<%=PopFile%> method="POST">
<b>Photo Album:</b>
<select name="go" onChange="jumppage(this);" size=1>
<%
ShowSub = request("ShowSub")
ShowPic = request("ShowPic")
strPathInfo = Request.ServerVariables("PATH_INFO")
strPhysicalPath = Server.MapPath(strPathInfo)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPhysicalPath)
Set objFolder = objFile.ParentFolder
Set objFolderContents = objFolder.Files
For each Folder in objFolder.SubFolders
If Left(Folder.Name,1)<>"_" Then
Response.write "<option "
If ShowSub=Folder.Name Then
Response.Write "selected "
End if
Response.Write"value='" & CurFile & "?ShowSub="
Response.Write(Replace(Folder.Name, " ", "%20"))
response.write "'>"
Response.Write(Folder.Name & "</option>")
If ShowSub <= " " Then
ShowSub = Folder.Name
End if
End if
Next
Set objFSO = Nothing
%>
</select></h3>
</form>
</tr>
</table>
<%
If ShowPic > " " then
ShowPic = Replace(ShowPic, " ", "%20")
Response.Write "<a href='JavaScript:history.go(-1)'><img src='"
& ShowPic & "'><BR><BR><font face=""verdana"" size=""""><b>Go
Back</b></a>"
Else
%>
<table border="0" cellpadding="0" cellspacing="5"
style="border-collapse: collapse" bordercolor="#000000"
width="100%" id="AutoNumber1">
<tr>
<%
strPhysicalPath = Server.MapPath(".\" & ShowSub)
If ShowSub > " " then
ShowSub = Replace(ShowSub, " ", "%20")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPhysicalPath)
Set objFolderContents = objFolder.Files
'Get the number of pictures in the subdirectory
intTotPics = 0
For Each objFileItem in objFolderContents
If Ucase(Right(objFileItem.Name,4))=".GIF" OR
Ucase(Right(objFileItem.Name,4))=".JPG" THEN
intTotPics = intTotPics + 1
End if
Next
'Get the total number of pages in the subdirectory
If (intTotPics/intPicsPerPage) =
(int(intTotPics/intPicsPerPage)) Then
intTotPages = int(intTotPics/intPicsPerPage)
Else
intTotPages = int(intTotPics/intPicsPerPage)+1
End If
Redim strPicArray(2,intTotPics)
'Store picture file names in an array
x = 0
For Each objFileItem in objFolderContents
If Ucase(Right(objFileItem.Name,4))=".GIF" OR
Ucase(Right(objFileItem.Name,4))=".JPG" THEN
strPicArray(0,x) = objFileItem.Name
strPicArray(1,x) = Cstr(int(x/intPicsPerPage)+1)
x = x + 1
End if
Next
'Determine if there are multiple pages and if so, display page
numbers.
If intTotPages > 1 Then
Response.Write "<td colspan='" & intPicsPerRow & "'
align='center'><p>Page: "
For x = 1 to intTotPages
If x = intPage Then
Response.Write "<font>" & x &
"</font><font> "
Else
Response.Write "<a href='sport_fotoalbum.asp?Page=" & x &
"&ShowSub=" & ShowSub & "'>" & x & "</a> "
End If
Next
Response.Write "</font></P></td>"
Response.Write "</tr><tr><td> </td></tr><tr>"
End If
For x = 0 to UBound(strPicArray,2)-1
If CInt(strPicArray(1,x)) = intPage Then
ShowPic = Replace(strPicArray(0,x), " ", "%20")
Response.write "<td align='center' width='25%'><a
href=""Javascript
enGalleryWindow('" & PopFile & "?ShowPic=" &
ShowSub & "/" & ShowPic & "')"""
Response.write "<br>"
Response.Write("<img src='" & ShowSub & "/" & strPicArray(0,x)
& "' height=150 width=150> ")
Response.Write("<br><font color=""" & strBaseFontColor &
"""><b>" & Mid(strPicArray(0,x),1,Len(strPicArray(0,x))-4) &
"</b></font>")
Response.write "</a></td>" & vbcrlf
PictureNo = PictureNo + 1
If PictureNo=intPicsPerRow Then
Response.write "</tr><tr>"
PictureNo = 0
End if
End If
Next
Set objFSO = Nothing
End if
%>
</tr>
</table>
<%
End if
%>
</center>
</td>
Håber I kan hjælpe mig
Flemming
(Bedre til copy & paste end til programmering;)
--
Vil du lære at kode HTML, XHTML, CSS, SSI eller ASP?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials