上传完成后如何重定向到 URL Onclick?
How to Redirect to URL Onclick after upload is complete?
$("#fileThumbnail").on("change", function(event) {
selectedFile = event.target.files[0];
});
function uploadThumb() {
var filename = selectedFile.name;
var storageRef = firebase.storage().ref('/Thumbs/' + filename);
var uploadThumb = storageRef.put(selectedFile);
uploadThumb.on('state_changed', function progress(snapshot){
var percentage = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
uploader.value = percentage;
$('.thumbsubmit-btn').click(function() {
window.location.href = 'index.html';
return false;
});
}, function(error) {
}, function () {
});
}
我试图在点击时重定向到另一个 url,但在上传完成后。
我怎么做?进度条正在运行,文件也在上传中。
只是不知道如何将此重定向添加到我的函数中,以便按钮上传文件
然后在上传完成后触发重定向。
$("#fileThumbnail").on("change", function(event) {
selectedFile = event.target.files[0];
});
function uploadThumb() {
var filename = selectedFile.name;
var storageRef = firebase.storage().ref('/Thumbs/' + filename);
var uploadThumb = storageRef.put(selectedFile);
uploadThumb.on('state_changed', function progress(snapshot){
var percentage = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
uploader.value = percentage;
$('.thumbsubmit-btn').click(function() {
window.location.href = 'index.html';
return false;
});
}, function(error) {
}, function () {
window.location.href = "index.html";
});
}
所以我想通了。刚刚在最后一个函数
上添加了 window.location.href = "index.html";
$("#fileThumbnail").on("change", function(event) {
selectedFile = event.target.files[0];
});
function uploadThumb() {
var filename = selectedFile.name;
var storageRef = firebase.storage().ref('/Thumbs/' + filename);
var uploadThumb = storageRef.put(selectedFile);
uploadThumb.on('state_changed', function progress(snapshot){
var percentage = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
uploader.value = percentage;
$('.thumbsubmit-btn').click(function() {
window.location.href = 'index.html';
return false;
});
}, function(error) {
}, function () {
});
}
我试图在点击时重定向到另一个 url,但在上传完成后。 我怎么做?进度条正在运行,文件也在上传中。 只是不知道如何将此重定向添加到我的函数中,以便按钮上传文件 然后在上传完成后触发重定向。
$("#fileThumbnail").on("change", function(event) {
selectedFile = event.target.files[0];
});
function uploadThumb() {
var filename = selectedFile.name;
var storageRef = firebase.storage().ref('/Thumbs/' + filename);
var uploadThumb = storageRef.put(selectedFile);
uploadThumb.on('state_changed', function progress(snapshot){
var percentage = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
uploader.value = percentage;
$('.thumbsubmit-btn').click(function() {
window.location.href = 'index.html';
return false;
});
}, function(error) {
}, function () {
window.location.href = "index.html";
});
}
所以我想通了。刚刚在最后一个函数
上添加了 window.location.href = "index.html";