Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Age Verification

I'm using a javascript for the age verification and did an alert. I was wondering if they type in 17 yrs and younger how to i forward it to google instead of just an alert.

5 Answers

Hi Maruja,

What do you mean about "how to i forward it to google"?

I assume you're talking about a redirct.

Check out the answer marked best here. http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page

However, just my .02 I wouldn't redirect people to another website. Could create a trust issue and negatively affect user experience. IMO page redirects should only happen within your own site. I.E. redirecting from one of your pages to another one of your pages, like if someone logged in, redirect them to the homepage.

Yes direct them to google. I mention the client but thats what they wanted?

Ah well if the client insists. All your duty is to help steer the client in what you think is the best decision. Give them the information but if they still decided to do it than do it. It's not immoral or wrong, it's just not great.

Like I said,check out that link. Basically I'd try using window.location.replace(...)

Ill try that

Thanks

that didn't work

this is what i have

<script language="javascript"> var agePrompt=prompt("What is your age?");

if (agePrompt>=18) alert('Welcome!') else {

alert('Sorry! Come back in a few years!') ----> I want to redirect this to google instead of using an alert document.location="http://www.vapinologywholesale.com/";