Need help with Javascript that worked in IE6 but gives "out of memory" error in IE7

K

khiser

I was using code by Mike Olsen that allowed a users to preview a file
prior to uploading the image to the server. Things have worked well
for over 1 1/2 years and this code has not been changed. Lately I have
had a few users of my code report an error that states "out of memory
at line: 56". At first I thought it was a flash issue as I see this
when researching Flash Player 9 but the code never gets to the flash
popup window. (which just has an animation saying "please wait")

Here is the code that I am using for the image preview. Can anyone
help me with this as I am not a strong Javascript person.

<script language="javascript">
<!--mike olsen-->
<!--June 2 2003: updated on June 17 2003-->
<!--//////////EDIT BELOW//////////-->
var YourPictureURL = "images/noimage.gif"
<!--Change this to your blank Image, or download mine for yourself-->
var YourMessage = 'Please select a valid image file.'
<!--Change this to your message you want on error-->
var BlankImgHieght = "100"
<!--Change this to your blank images hieght-->
var BlankImgWidth = "100"
<!--Change this to your blank images width-->
var MaxWidth = "150"
<!--Change this to your images maximum width, the hieght is changed by
the ratio of the uploaded Image-->
var CanExeOrNot = "TRUE"
<!--Change this to "FALSE" or "TRUE", true meaning upload required and
false meaning not required, leaving the double quotes and using only
uppercase letters-->
<!--\\\\\\\\\\\DONE EDIT BELOW\\\\\\\\\\\-->
function LoadBlankImage() {
document.images.theimage.src=YourPictureURL
document.images.theimage.height=BlankImgHieght
document.images.theimage.width=BlankImgWidth
}
function DoneNowPic(what, type) {
if (CanExeOrNot=="FALSE") {
return true
} else {
var filename = "";
var TheWidth = what.width
var TheHeight = what.height
var PicIndex = what.lastIndexOf('.', what.length - 1);
var PicFileExtension = what.substr(PicIndex + 1).toLowerCase();
if ((PicFileExtension != 'jpg') && (PicFileExtension != 'gif') &&
(PicFileExtension != 'jpeg') && (PicFileExtension != 'bmp') &&
(PicFileExtension != 'png')) {
window.alert(YourMessage);
document.images.theimage.src=YourPictureURL
document.images.theimage.height=BlankImgHieght
document.images.theimage.width=BlankImgWidth
return false;
} else {
filename = "file:///" + document.fmupload.file.value;
document.images.theimage.src=filename
var TempRatio = ""
var TempImage = new Image()
TempImage.src = filename
if (!TempImage.width) {
DoneNowPic(what, type)
} else {
TempWidth = TempImage.width
TempHeight = TempImage.height
TempRatio = TempWidth / TempHeight
if (TempWidth == TempHeight) {
MaxHeight=MaxWidth
document.images.theimage.height=MaxHeight
document.images.theimage.width=MaxWidth
} else {
var TempMathEqu = Math.round(TempRatio*100)/100
var TempMathFxw = 150 / TempMathEqu
var TempMathPqr = Math.round(TempMathFxw)
document.images.theimage.width=MaxWidth
document.images.theimage.height=TempMathPqr
}
}
}
}
}
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top