Avatar billede -42- Nybegynder
04. juli 2003 - 10:55 Der er 24 kommentarer og
1 løsning

new window

Hejsa! Jeg har et problem med dette dokument som bliver vist i en iframe. Det viser billederne fra en folder, men når man klikker på thumbnailen skal det store billed vises i et nyt vindue...

Det skal siges at jeg ikke er en haj til asp.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Photo Album</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<%

' This code assumes you are using .jpg images for both the thumbnails and fullsize pictures. If you are
' using .gif then you will have to change it everywhere in the code.
' This also assumes that your thumbnails share the same name as your original with a common ending.
'  e.g. Faimily-01.jpg - would be the thumbnail
'      Family.jpg    - would be the large image

'Declare variables
dim thumbIdentifier    'The unique string that identifies a thumbnail vs. the big image
dim thumbsPerPage      'Number of thumbnails per page
dim thumbsPerRow      'Number of thumbnails per row
dim img                'The image to display (not the thumbnail but the big one)
dim page              'what page you are on
dim first              'first image of the set to display, a set being image 0-49 based upon number per page
dim last              'last image of the set for the array
dim lastDisplay        'last image of the set to display on the 'Images 20 - 40'
dim thisPageURL        'This is the name of this page eg. album.asp. If you re-name it links in page will update

thumbsPerPage = 200              ' Number of thumbnails to display on the page
thumbIdentifier = "-01.jpg"      ' This is the common string ending for all thumbnail images.
thumbsPerRow = 3                ' Number of thumbnails to display per row - surprised?
thisPageURL = Request.ServerVariables("gallery.asp") 'This gets the name of this page eg. album.asp
page = request.queryString("page") 'This is the page you are on, used for paging
if page = "" then page = 1        'If no page # exists, set to 1
img = Request.querystring("img")  'Large image to display if they clicked a thumbnail
if img = "" then                  'If there is no image on URL, show the thumbnail page

' Determine which image to start / end at based upon paging and thumbsPerPage
first = ((page-1) * thumbsPerPage)
last = (page * thumbsPerPage)-1 'We do minus 1 here since we are using an array... array starts at 0 vs 1

  ' get the current folder location
    strPathInfo = Request.ServerVariables("SCRIPT_NAME")
    strPhysicalPath = Server.MapPath(strPathInfo)
    set objFSO = CreateObject("Scripting.FileSystemObject")
    set objFile = objFSO.GetFile(strPhysicalPath)
    set objFolder = objFile.ParentFolder
    set objFolderContents = objFolder.Files
   
  ' Count total number of thumbnails
  totalImages = 0
  For each objFileItem In objFolderContents
      if inStr(LCase(objFileItem.Name),thumbIdentifier) then
          totalImages = totalImages + 1
      end if
  next
 
'Limit last to totalImages so array does not go out of range.
if last > totalImages then last = totalImages

'Array starts at 0 vs. 1 so we need to offset this by 1 exception last image can'be be > than total # of images
lastDisplay = last + 1
if lastDisplay > totalImages then lastDisplay = totalImages
 
  ' Create an array to put all the images in so that we can do paging
  dim arrayOfThumbs()
  ReDim arrayOfThumbs(totalImages)
 
  dim i
  i = 0
' Populate the array with the images
For each objFileItem In objFolderContents
                ' only display the thumbnails - the images that have the ending defined in the thumbIdentifier variable at top of page
                if inStr(LCase(objFileItem.Name),thumbIdentifier) then
          'Isolate the image name so that we can create a link to the large version. This strips off the ending e.g. -01.jpg
                    image = split(objFileItem.Name, thumbIdentifier)
        ' Populate array
                arrayOfThumbs(i)= "<td nowrap valign='bottom' align='left'><a href='gallery.asp? img=" & image(0) & ".jpg'>" & vbCrLf & _
                                  "<img src='" & objFileItem.Name & "' hspace='2' border='0'></a><br><input type='checkbox' name='"&image(0) &"' id='"&image(0) &"' value='checkbox'>" &" Order CD</td><td width='20'></td>" & vbCrLf
        i = i + 1
        end if
next


' Create page links if more than 1 page is needed
dim paging
if (thumbsPerPage < totalImages) then
' Assing all the page numbers to the paging string because we are going to use on top and bottom of page
paging = "Page: <b>"
  k = 1
  Do
    paging = paging + "<a href='" & thisPageURL & "?page=" & k & "'>" & k & "</a>" & vbCrLf
    k = k + 1
  loop until (k * thumbsPerPage) >= totalImages
  paging = paging + "<a href='" & thisPageURL & "?page=" & k & "'>" & k & "</a></b>"    'One more becase the logic cuts the last one off
end if
%>

<!-- This is where the HTML of the page starts :::: Page Title -->




<table align="center">
  <tr>
<%
' Loop through the array and display images
  for j =  first to last
    response.write(arrayOfThumbs(j))
    if (j+1) Mod thumbsPerRow = 0 then response.Write(vbCrLf & "</tr><tr>" & vbCrLf) 'Create a new row based on thumbsPer row
  next
%>
  </tr>
</table>
<!-- Write the paging piece at the bottom
<p align="center">
<%=paging%> &nbsp;&nbsp; Images <%=first+1%> - <%=lastDisplay%> of <%=totalImages%>
</p> -->

<%
'Display the big image Page
else
%>
<!-- Else show the selected picture.  -->


  <p align='center'>
  <a href='java script:history.back()'>
  <img src=' <%=img%>  '  align='center' border=1></a><br><br>
  <a href='java script:history.back()'>Back</a>
  </p>
 
<% end if %>
</body>
</html>
Avatar billede tuctoh Nybegynder
04. juli 2003 - 10:58 #1
måske:


' Populate array
                arrayOfThumbs(i)= "<td nowrap valign='bottom' align='left'><a href='gallery.asp? img=" & image(0) & ".jpg' target='_blank'>" & vbCrLf & _
Avatar billede -42- Nybegynder
04. juli 2003 - 11:04 #2
Næsten! Nu åbner den hele indholdet af iframen i et nyt vindue. Dvs. alle thumbnailsne.
Avatar billede tuctoh Nybegynder
04. juli 2003 - 11:10 #3
prøv at udskifte:

  <p align='center'>
  <a href='java script:history.back()'>
  <img src=' <%=img%>  '  align='center' border=1></a><br><br>
  <a href='java script:history.back()'>Back</a>
  </p>


med:

  <script language='javascript'>
  window.open('<%=img%>')
  history.back() 
  </script>
Avatar billede -42- Nybegynder
04. juli 2003 - 11:24 #4
Her kan du se siden. Det er dog uden den sidste ændring, men det virkede desvære heller ikke.
http://www.cbc.dk/GACphotolibrary/
Avatar billede tuctoh Nybegynder
04. juli 2003 - 11:30 #5
den sidste ændring skal tilkobles den originale kode; ikke den kode som du lavede efter min ændring... hvis du normalt får vist det store billede ved at klikke på thumbnailsene burde det andet nu også virke :s
Avatar billede -42- Nybegynder
04. juli 2003 - 11:30 #6
http://www.cbc.dk/GACphotolibrary/
Så nu er den opdateret
Avatar billede -42- Nybegynder
04. juli 2003 - 11:31 #7
Ok så det første skal ændres tilbage til det originale?
Avatar billede tuctoh Nybegynder
04. juli 2003 - 11:32 #8
ja, det skal det nemlig... du skal fra den originale smide
<script language='javascript'>
  window.open('<%=img%>')
  history.back() 
  </script>
 

ind
Avatar billede -42- Nybegynder
04. juli 2003 - 11:42 #9
Den gør det samme nummer! Det er som om den bare linker til sig selv
Avatar billede tuctoh Nybegynder
04. juli 2003 - 11:44 #10
med den kode jeg viste burde den nu åbne billedet for sig selv :s
Avatar billede -42- Nybegynder
04. juli 2003 - 11:57 #11
Det gør den desvære ikke! Men det ser ellers logisk nok ud. Har du testet det?
Avatar billede tuctoh Nybegynder
04. juli 2003 - 11:59 #12
nej, har ikke de komponenter der skal til... men hvis du uploader den samme sted kan jeg da se hvorfor det ikke virker
Avatar billede -42- Nybegynder
04. juli 2003 - 12:00 #13
Hvis du kan lave det plus lave det muligt at downloade det store billed, så er der en pizza hjemme fra www.justeat.dk  ;-)
Avatar billede -42- Nybegynder
04. juli 2003 - 12:01 #14
nu hedder den www.cbc.dk/GACphoto
Avatar billede tuctoh Nybegynder
04. juli 2003 - 12:08 #15
prøv:





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Photo Album</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<%

' This code assumes you are using .jpg images for both the thumbnails and fullsize pictures. If you are
' using .gif then you will have to change it everywhere in the code.
' This also assumes that your thumbnails share the same name as your original with a common ending.
'  e.g. Faimily-01.jpg - would be the thumbnail
'      Family.jpg    - would be the large image

'Declare variables
dim thumbIdentifier    'The unique string that identifies a thumbnail vs. the big image
dim thumbsPerPage      'Number of thumbnails per page
dim thumbsPerRow      'Number of thumbnails per row
dim img                'The image to display (not the thumbnail but the big one)
dim page              'what page you are on
dim first              'first image of the set to display, a set being image 0-49 based upon number per page
dim last              'last image of the set for the array
dim lastDisplay        'last image of the set to display on the 'Images 20 - 40'
dim thisPageURL        'This is the name of this page eg. album.asp. If you re-name it links in page will update

thumbsPerPage = 200              ' Number of thumbnails to display on the page
thumbIdentifier = "01.jpg"      ' This is the common string ending for all thumbnail images.
thumbsPerRow = 3                ' Number of thumbnails to display per row - surprised?
thisPageURL = Request.ServerVariables("test.asp") 'This gets the name of this page eg. album.asp
page = request.queryString("page") 'This is the page you are on, used for paging
if page = "" then page = 1        'If no page # exists, set to 1
img = Request.querystring("img")  'Large image to display if they clicked a thumbnail
if img = "" then                  'If there is no image on URL, show the thumbnail page

' Determine which image to start / end at based upon paging and thumbsPerPage
first = ((page-1) * thumbsPerPage)
last = (page * thumbsPerPage)-1 'We do minus 1 here since we are using an array... array starts at 0 vs 1

  ' get the current folder location
    strPathInfo = Request.ServerVariables("SCRIPT_NAME")
    strPhysicalPath = Server.MapPath(strPathInfo)
    set objFSO = CreateObject("Scripting.FileSystemObject")
    set objFile = objFSO.GetFile(strPhysicalPath)
    set objFolder = objFile.ParentFolder
    set objFolderContents = objFolder.Files
   
  ' Count total number of thumbnails
  totalImages = 0
  For each objFileItem In objFolderContents
      if inStr(LCase(objFileItem.Name),thumbIdentifier) then
          totalImages = totalImages + 1
      end if
  next
 
'Limit last to totalImages so array does not go out of range.
if last > totalImages then last = totalImages

'Array starts at 0 vs. 1 so we need to offset this by 1 exception last image can'be be > than total # of images
lastDisplay = last + 1
if lastDisplay > totalImages then lastDisplay = totalImages
 
  ' Create an array to put all the images in so that we can do paging
  dim arrayOfThumbs()
  ReDim arrayOfThumbs(totalImages)
 
  dim i
  i = 0
' Populate the array with the images
For each objFileItem In objFolderContents
                ' only display the thumbnails - the images that have the ending defined in the thumbIdentifier variable at top of page
                if inStr(LCase(objFileItem.Name),thumbIdentifier) then
          'Isolate the image name so that we can create a link to the large version. This strips off the ending e.g. -01.jpg
                    image = split(objFileItem.Name, thumbIdentifier)
        ' Populate array
                arrayOfThumbs(i)= "<td nowrap valign='bottom' align='left'><a href='gallery.asp?img=" & image(0) & ".jpg'>" & vbCrLf & _
                                  "<img src='" & objFileItem.Name & "' hspace='2' border='0'></a><br><input type='checkbox' name='"&image(0) &"' id='"&image(0) &"' value='checkbox'>" &" Order CD</td><td width='20'></td>" & vbCrLf
        i = i + 1
        end if
next


' Create page links if more than 1 page is needed
dim paging
if (thumbsPerPage < totalImages) then
' Assing all the page numbers to the paging string because we are going to use on top and bottom of page
paging = "Page: <b>"
  k = 1
  Do
    paging = paging + "<a href='" & thisPageURL & "?page=" & k & "'>" & k & "</a>" & vbCrLf
    k = k + 1
  loop until (k * thumbsPerPage) >= totalImages
  paging = paging + "<a href='" & thisPageURL & "?page=" & k & "'>" & k & "</a></b>"    'One more becase the logic cuts the last one off
end if
%>

<!-- This is where the HTML of the page starts :::: Page Title -->




<table align="center">
  <tr>
<%
' Loop through the array and display images
  for j =  first to last
    response.write(arrayOfThumbs(j))
    if (j+1) Mod thumbsPerRow = 0 then response.Write(vbCrLf & "</tr><tr>" & vbCrLf) 'Create a new row based on thumbsPer row
  next
%>
  </tr>
</table>
<!-- Write the paging piece at the bottom
<p align="center">
<%=paging%> &nbsp;&nbsp; Images <%=first+1%> - <%=lastDisplay%> of <%=totalImages%>
</p> -->

<%
'Display the big image Page
else
%>
<!-- Else show the selected picture.  -->


<script language='javascript'>
  window.open('<%=img%>')
  history.back() 
  </script>
 
<% end if %>
</body>
</html>
Avatar billede tuctoh Nybegynder
04. juli 2003 - 12:15 #16
ok, i mit script.

linien hvor der står
thumbIdentifier = "01.jpg"

skal så være
thumbIdentifier = "-01.jpg"
Avatar billede -42- Nybegynder
04. juli 2003 - 12:18 #17
nu ser den ret "sjov" ud...
Avatar billede tuctoh Nybegynder
04. juli 2003 - 12:22 #18
hehe, ja lidt ;)

smid den streg ind som jeg skrev oven over :p
Avatar billede -42- Nybegynder
04. juli 2003 - 12:32 #19
WWWEeeeeeehhhhhuuuuuuuuu!!!!! :-)

IT WORKS!!!

Mange tak!

Så er der point! -Hvis du kan lave den downloadfunktion, så er der også en pizza hjemme...
Avatar billede tuctoh Nybegynder
04. juli 2003 - 12:39 #20
nej tak, prøver at tabe mig :p

opret et nyt spørgsmål for download funktionen... du skal have at vide hvordan man tvinger et billede til at blive downloadet.
jeg skal nok hjælpe dig med at implementere det i scriptet.
Avatar billede -42- Nybegynder
04. juli 2003 - 13:11 #21
Så er der oprettet en nyt!
Avatar billede -42- Nybegynder
04. juli 2003 - 14:01 #22
Hey jeg fandt det her script, kan du hjælpe med at implementere det, hvis det virker?

How can I call save as on an IMG/Image?
Mar 31st, 2000 05:16

Martin Honnen





IE supports
  document.execCommand('SaveAs')
to save the current page. It looks as if you can also open a page with
an image in it and then call the command on the image page:

  function saveImageAs (imgOrURL) {
    if (typeof imgOrURL == 'object')
      imgOrURL = imgOrURL.src;
    window.win = open (imgOrURL);
    setTimeout('win.document.execCommand("SaveAs")', 500);
  }
  <A HREF="java script: void 0"
    ONCLICK="saveImageAs(document.anImage); return false"
  >save image</A>
  <IMG NAME="anImage" SRC="whatever.gif">

Note that the img needs to be on the same server as the script.
Avatar billede -42- Nybegynder
04. juli 2003 - 14:01 #23
Så kan du få pointne i det andet spørgsmål
Avatar billede tuctoh Nybegynder
04. juli 2003 - 15:14 #24
lad mig kigge lidt på sagen :)
Avatar billede -42- Nybegynder
04. juli 2003 - 15:16 #25
Lækkert!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester