Javascript problem

Asked

Viewed 56 times

0

I have a problem with my javascript code:

function() {
            var largura = document.getElementById('fundo').width;
            console.log("Largura da imagem:" + largura);
            try{
            new Cropper.Img(
                'fundo',
                {
                    onEndCrop: onEndCrop,
                    displayOnInit: true,
                    onloadCoords: { x1: 0, y1: 0, x2: largura, y2: largura },
                    ratioDim: { x: largura, y: largura }
                }
            );
            }catch(e){
                console.log('ERRO');
            }
        }

This function is responsible for sending the size of an image to another script, which will show on top of the image a square to cut. My problem is you’re not getting into new Cropper.Img. The error the browser displays: Uncaught Typeerror: Cannot read Property 'Img' of Undefined. If anyone can help me I’d be very grateful, that code is part of a college job.

  • Which component you are using (Cropper) and its documentation page?

  • http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/ At this link you can download the file, it’s Cropper.js

  • Just drop the zip

1 answer

0


From what I saw, to use the Cropper it is necessary to add the following scripts:

  <script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js" type="text/javascript"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js" type="text/javascript"></script>

You can test here by clicking on the "cropperIt".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.