问题
I am new to both Javascript and php. I have a site with a form that goes through some php mumbo jumbo. After that, I check my database to see if the login credentials exist. If they don't, I want to show a div that contains the error message.
oldURL = document.referrer;
console.log(oldURL);
if (oldURL =="http://amazingwebsite.com/") {
document.getElementById("loginfail").removeAttribute("hidden");
document.getElementById("textlogin").removeAttribute("hidden");
}
oldURL returns the exact url that I have in my if statement. However, the if statement only works if I have oldURL to 'not equal' (==!).
What have I missed?
回答1:
Thx to @T30, I figured it out. Was apparently a problem with the CSS not anything with the php code or the javascript.
来源:https://stackoverflow.com/questions/46643399/getelementbyid-with-document-reffer