Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Having a Problem With an 'Access is Denied' Error, Only In IE7

    I've been working on a sort of photography gallery that lets users display photos (organized in albums). One of the features of the gallery is some javascript code that pulls EXIF data from the photos, and then formats it and displays it (stuff like exposure, shutter speed, camera make/model, etc.)

    Now, this all works perfectly in Internet Explorer 8, Firefox, and Safari, but IE7 has problems. The process works like this (when the user clicks the 'Info' button): getExifData() function retrieves raw EXIF data from the photo, and then formats it and cleans it up to be displayed; since the exposure comp. and shutter speed are reported as decimals, I use another function to convert them into fractions. This is where IE7 throws the error:

    'Access is Denied', 'Code 0' on Line 184, character 4.

    Here's the getExifData() function:
    Code:
    function getExifData() {
      var oImg = new Image();
      oImg.exifdata = null
      oImg.src = 'albums/'+sessvars.currentAlbumFolderName+'/'+sessvars.currentPhotoFileName+'.jpg'
      //alert('albums/'+sessvars.currentAlbumFolderName+'/'+sessvars.currentPhotoFileName+'.jpg');
      EXIF.getData(oImg, displayData);
      function displayData(){
        exifResolution = (Math.round(((oImg.width * oImg.height)/1000000)*10)/10)+" megapixels";
         if ((Math.round(((oImg.width * oImg.height)/1000000)*10)/10)<.1) {exifResolution="--"}
        exifDimensions = oImg.width+" x "+oImg.height;
        exifDateTaken = String(EXIF.getTag(oImg, "DateTime"))
        if (exifDateTaken!="undefined") {
          exifDateTaken = (EXIF.getTag(oImg, "DateTime").substring(5,7))+"/"+(EXIF.getTag(oImg, "DateTime").substring(8,10))+"/"+(EXIF.getTag(oImg, "DateTime").substring(0,4))
            } else{
              exifDateTaken = "--"
            }
            exifMake = EXIF.getTag(oImg, "Make");
            exifModel = EXIF.getTag(oImg, "Model");
            exifShutter = (fractApprox(parseFloat(EXIF.getTag(oImg, "ExposureTime")),10000))+" sec";
            exifAperture = "f/"+EXIF.getTag(oImg, "FNumber");
            exifExposureComp = fractApprox(parseFloat(EXIF.getTag(oImg, "ExposureBias")),1000)+" step";
            if (parseFloat(exifExposureComp)>0) {
              exifExposureComp = "+"+exifExposureComp
            }
            exifExposure = EXIF.getTag(oImg, "ExposureProgram");
            exifFocalLength = Math.round(parseFloat(EXIF.getTag(oImg, "FocalLength")))+"mm";
            exifMetering = EXIF.getTag(oImg, "MeteringMode");
            if (String(exifMake)=="undefined") {exifMake="--"}
            if (String(exifModel)=="undefined") {exifModel="--"}
            if (String(exifShutter)=="NaN/1 sec") {exifShutter="--"}
            if (String(exifAperture)=="f/undefined") {exifAperture="--"}
            if (String(exifExposureComp)=="NaN/1 step") {exifExposureComp="--"}
            if (String(exifExposureComp)=="0/1 step") {exifExposureComp="0 step"}
            if (String(exifExposure)=="undefined") {exifExposure="--"}
            if (String(exifFocalLength)=="NaNmm") {exifFocalLength="--"}
            if (String(exifMetering)=="undefined") {exifMetering="--"}
            $("#info_text").html(exifResolution+'<br />'+exifDimensions+'<br />'+exifDateTaken+'<br /><br />'+exifMake+'<br />'+exifModel+'<br /><br />'+exifShutter+'<br />'+exifAperture+'<br />'+exifExposureComp+'<br />'+exifExposure+'<br />'+exifFocalLength+'<br />'+exifMetering+'<br />');
        $("#info_labels").css({"visibility": "visible"});
        $("#info_text").css({"visibility": "visible"});
        $("#loading_text").css({"visibility": "hidden"});
      }
    }
    But when it runs, it only ends up displaying the camera make and model (albeit correctly) and everything else is not displayed.

    And the fractApprox() function, to convert the decimal to fraction:
    Code:
    function fractApprox(x,maxDenominator) {
            try {
            // Created 1997 by Brian Risk.  http://brianrisk.com
            maxDenominator = parseInt(maxDenominator);
            var approx = 0;
            var error = 0;
            var best = 0;
            var besterror = 0;
            for (var i=1; i <= maxDenominator; i++) {
                    approx = Math.round(x/(1/i));
                    error = (x - (approx/i))
                    if (i==1) {best = i; besterror = error;}
                    if (Math.abs(error) < Math.abs(besterror)) 
                            {best = i; besterror = error;}
            }
            return (Math.round(x/(1/best)) + "/" + best);
            } catch(err){
            return (Math.round((x*100)/100));
            }
    }
    My main problem is, IE7 incorrectly reports the error, so I can't find where it actually is- I can comment out line 184, add or remove lines above it, whatever, but the error doesn't change at all.

    I read about access denied errors online but they all seem to be related to accessing an external document, which I'm not doing in any way.

    Anyway, to take a look at the full page (make sure you're in IE7 to see the error), go to http://www.labusdesign.com/photography/index.html , and then click on any of the albums. Then, click on one of the photo thumbnails and click the 'Photo Info' button. (NOTE: only the very first photo in the 'Wedding' album should display any data, such as the camera make/model- it's the only one that has any EXIF data).

    Thanks for any help!

    EDIT: Damn, I just realized that the error doesn't come up when viewing it online- only locally. However, the same problem still occurs- only the camera make/model are displayed, everything else is blank, so I know the error is still happening.
    Last edited by blabus; 06-02-2009 at 04:12 PM.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •