Reputation: 51
Hello i am currently trying to get this to work so that when the user visits the page for the webpage for the first time it asks them to enter a name into the input box and then future visits will display their name with SweetAlert. my attempt bellow
function checkCookie() {
var user=getCookie("username");
if (user != "") {
swal("Welcome again " + user);
} else {
user = prompt; swal({
title: 'Input Username',
html: '<p><input id="input-field">',
showCancelButton: true,
closeOnConfirm: false,
allowOutsideClick: false
});
However when i try to load the page for the first time it displays the input box but after entering text and reloading the page it shows this
Welcome again function prompt() { [native code] }
The Full js file is located here for review
https://joshsmotions.co.uk/scripts/cookie-script.js
The domain i am implementing this on is https://joshsmotions.co.uk
Upvotes: 1
Views: 36
Reputation: 5483
Oh, I see. user
shouldn't be equal to prompt
. It should be equal to prompt()
.
Upvotes: 2