My jquery code for the hijacked iframe image upload is working in FF, not Safari. Any ideas?
Can anyone see why this would work in FF but not Safari? When I alert the return from my CF script that processes the image and returns the image name it works in FF. No go in Safari...
$( "#uploadform" ).submit(function( objEvent ){
//alert("Submit");
var jThis = $( this );
var strName = ("uploader" + (new Date()).getTime());
var jFrame = $( "<iframe name=\"" + strName + "\" src=\"about:blank\" />" );
jFrame.css( "display", "none" );
jFrame.load(function( objEvent ){
var objUploadBody = window.frames[ strName ].document.getElementsByTagName( "body" )[ 0 ];
var jBody = $( objUploadBody );
var objData = eval(jBody.html());
var thumb = ('holding/' + eval(jBody.html()));
setTimeout(function(){
jFrame.remove();
},100);
if (objData !== '') {
// Put the preview here and load another form that has a hidden element capturi开发者_如何学Pythonng the image name
// then use a button to save the image, close the window and update the database with all the info
// and relaod the main page with a location.reload
$('#imagePreview').attr('src', thumb );
$('#imageName').html(thumb);
$('#imagePreview').click(function(){
rebinder();
});
} else {
alert("no thumbnail");
}
});
$( "body:first" ).append( jFrame );
jThis
.attr( "action", "upload_act_single.cfm" )
.attr( "method", "post" )
.attr( "enctype", "multipart/form-data" )
.attr( "encoding", "multipart/form-data" )
.attr( "target", strName );
});
I'm thinking I must have some syntax errors messing up the works but I'm new enough to this to not see it. When I use the alert to call out the objData variable it says 'undefined' in Safari. It acts like it doesn't even run the CF script... Thank you in advance for any help.
Instead of using about:blank, try to create your own empty HTML with the body tag. I did a view source in Safari 4 (windows) and Chrome. about:blank source has nothing in it unlike IE or Firefox which has HTML in it. Try to alert(objUploadBody) to see if you get anything it in too.
精彩评论