我有一个非常奇怪的情况,我正在这样调用我的javascript函数......
window.top.window.stopUpload(<? echo $result; ?>,<? echo $file_name; ?>);
Javascript函数看起来像这样,
function stopUpload(success,filePath){
var result = '';
if (success == 1){
result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
}
else {
result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
}
document.getElementById('f1_upload_process').style.visibility = 'hidden';
document.getElementById('f1_upload_form').innerHTML = result + '<input name="image_file" type="file" class="browse" /><input type="submit" name="submit_button" value="Upload" class="browse"/>';
document.getElementById('f1_upload_form').style.visibility = 'visible';
return true;
}
上面的代码不执行stopUpload
函数。
但是,如果我这样做,
window.top.window.stopUpload(<? echo $result; ?>);
和像这样的javascript,
function stopUpload(success){
var result = '';
if (success == 1){
result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
}
else {
result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
}
document.getElementById('f1_upload_process').style.visibility = 'hidden';
document.getElementById('f1_upload_form').innerHTML = result + '<input name="image_file" type="file" class="browse" /><input type="submit" name="submit_button" value="Upload" class="browse"/>';
document.getElementById('f1_upload_form').style.visibility = 'visible';
return true;
}
只需一个参数,它就可以工作!
问题
为什么它适用于一个参数而不适用于 2?我试过发送普通字符串,'hello'
而不是,$file_name
但它仍然没有调用。