Opening a new window to display various types of files

Discussion in 'JavaScript' started by z0isch, Jul 7, 2006.

  1. #1
    I wrote a perl cgi script to search for files and return their full directory information. How would i open a new window, load the file regardless of the type and display it?
    I will be dealing with mostly pdfs, excel spreadsheets and text files.
    Will I have to check the file type and then handle each different file type?

    I tried this NewWindow=window.open(dir);
    where dir is something like file:///C:/cgi/00000T.txt
    im guessing window.open is only used for html refrences???

    thank you!
     
    z0isch, Jul 7, 2006 IP
  2. AllYearFootball

    AllYearFootball Peon

    Messages:
    61
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    window.open should work for anything. If you are using a web server to serve the pages, it should set the mime type based on the extension of the file, my guess is that since you are using file:// you might get different results
     
    AllYearFootball, Jul 17, 2006 IP
  3. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #3
    yes, set the context header to Excel type, or XML Type, or whatever type of file it is - do this before you do Anything else - and it will launch your script as that type of file.
     
    ccoonen, Jul 18, 2006 IP