Linking to Google

javascript

#1

I am trying to connect to Google via Javascript on my project, yet when I do that, it says that “google.com” isn’t a file. Is there a way to overcome this problem and send someone to google after an alert?


#2

What did you try to do so far? Example of code you used will be helpful, since it is not quite clear what exactly does connect to Google mean


#3

Here is an example of the code. I’m making a password in a prompt box.

var password = prompt("Password Please.");

if(password === "Qwertu") {
    alert("Welcome Dylan");
}
else {
    alert("Go Away");
    window.location("google.com")
}

I’m trying to send the person with the incorrect answer to Google.


#4

First of all, please do not use this code in production, it is an extreme security risk. That said, while I’m not sure why you’d want to send the user to Google if they fail to log in, here’s the solution:

window.location.href = "google.com";