猿问

如果我删除警报,Javascript 重定向不起作用

我有一个重定向页面的功能。当我有这样的代码时,函数工作得很好。


document.getElementById("orderNow").addEventListener("click", function() {


// window.location.href = "http://www.w3schools.com", "_blank";

var name = document.getElementById("customerName").textContent;

var address = document.getElementById("customerStreet").textContent;

var city = document.getElementById("customerCity").textContent;

var state = document.getElementById("customerState").textContent;

var zip = document.getElementById("customerPcode").textContent;

var country = document.getElementById("customerCountry").textContent;

var phone = document.getElementById("customerPhone").textContent;


window.location.href = "https://www.amazon.com/gp/buy/addressselect/handlers/display.html?hasWorkingJavascript=1";



var username = document.getElementById('enterAddressFullName');



alert(username);

但是如果删除警报功能或这个:


var username = document.getElementById('enterAddressFullName');

重定向不起作用!


我不知道如何命名问题,但这是我的问题。我不想要最后两行代码。帮我修


皈依舞
浏览 183回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答