greenday Posted September 22, 2008 Share Posted September 22, 2008 Hi I am using PHP File Upload add on to Dreamweaver, and am getting some serious cross browser probs. Its an extension which allows form data file fields to upload to a directory, and insert the name into a DB. There are options to limit file size and dimensions etc. If the dimensions of the intended image are too big, an alert box will pop up with a message saying the size is too big. If you still try to submit the form regardless, the alert will come up again, and not allow the form to submit. This works fine in IE6, but in IE7 and FF3, the alerts will not appear (except if the file is not an image), and allows the form to be submitted, going to a detail error page with a back button. Once the back back is pressed, the form has lost all the inputed data, and the user gives up. Here is an extract from the js file which should give the alert: function showImageDimensions(fieldImg) { var is_ns6 = (!document.all && document.getElementById ? true : false); var img = (fieldImg && !is_ns6 ? fieldImg : this); if (img.width > 0 && img.height > 0) { if ((img.minWidth != '' && img.minWidth > img.width) || (img.minHeight != '' && img.minHeight > img.height)) { alert('Uploaded Image is too small!\nShould be at least ' + img.minWidth + ' x ' + img.minHeight); img.field.uploadOK = false; return; } if ((img.maxWidth != '' && img.width > img.maxWidth) || (img.maxHeight != '' && img.height > img.maxHeight)) { alert('Uploaded Image is too big!\nShould be max ' + img.maxWidth + ' x ' + img.maxHeight); img.field.uploadOK = false; return; } if (img.sizeLimit != '' && img.fileSize > img.sizeLimit) { alert('Uploaded Image File Size is too big!\nShould be max ' + (img.sizeLimit/1024) + ' KBytes'); img.field.uploadOK = false; return; } if (img.saveWidth != '') { document.PU_uploadForm[img.saveWidth].value = img.width; } if (img.saveHeight != '') { document.PU_uploadForm[img.saveHeight].value = img.height; } if (document.PU_uploadForm[img.field.name+'_width']) { document.PU_uploadForm[img.field.name+'_width'].value = img.width; } if (document.PU_uploadForm[img.field.name+'_height']) { document.PU_uploadForm[img.field.name+'_height'].value = img.height; } img.field.uploadOK = true; } } Any help much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/125237-cross-browser-alert-problems/ Share on other sites More sharing options...
SammyTheBear Posted October 16, 2012 Share Posted October 16, 2012 Has anybody figured this out? I am using similar code and the alerts are not working. They only work in IE6 and earlier. I am working on old pages and would like to know how to solve this. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/125237-cross-browser-alert-problems/#findComment-1385600 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.