Jump to content

Build Theme!
  •  
  • Infected?

WE'RE SURE THAT YOU'LL LOVE US!

Hey there! :wub: Looks like you're enjoying the discussion, but you're not signed up for an account. When you create an account, we remember exactly what you've read, so you always come right back where you left off. You also get notifications, here and via email, whenever new posts are made. You can like posts to share the love. :D Join 91981 other members! Anybody can ask, anybody can answer. Consistently helpful members may be invited to become staff. Here's how it works. Virus cleanup? Start here -> Malware Removal Forum.

Try What the Tech -- It's free!


Photo

Implementing a While Loop using Javascript for a Website


  • Please log in to reply
1 reply to this topic

#1 GaryORLFC

GaryORLFC

    Authentic Member

  • Authentic Member
  • PipPip
  • 56 posts
  • Interests:Sports, Music, Gaming, Computers & Drinks With Friends.

Posted 07 April 2010 - 04:46 PM

Hey there,

I am wondering if anyone knows how to, or can give me an example of a while loop that I can use for a website.

Looking online, I can;t seem to find any useful while loops that can be implemented into my website. I can't seem to think of any logical ones either apart from this one:

What I'm trying to do is when someone comes onto my website, I want them to be prompted using window.alert stating "Are you sure you want to enter this website? Please enter "Yes" to enter or "No" to leave the page. if they choose yes it will go to my Home.html page and if they choose "No" it will either return them to their homepage or to Google.

Does anyone know how to do this? I know it isn't the best While loop out there, but really it's just for show for a project. Please help if you can.

Note: It has to be a While loop. I do know how while loops work I'm just really having trouble implementing one to a website.

Posted Image

    Advertisements

Register to Remove


#2 appleoddity

appleoddity

    SuperMember

  • Tech Team
  • 3,071 posts
  • Interests:Eating, Movies, Family, Church, Music, Volleyball, Softball, Poker, Computers, Electronics, Reading.

Posted 09 April 2010 - 11:03 PM

I wish I knew more about Javascript to help you.

I did research this a little bit. According to these links:
http://www.sbrady.co...ript/popup.html
http://www.javascrip...rs/alert2.shtml

The method for requesting if a user wants to enter a page is with a confirm, not an alert. And the response is handled in a simple if statement.

I don't see how you are going to provide a yes/no option with a windows.alert. And, if you use window.confirm, then there is no reason for a loop. From what I can see there would be absolutely no reason to justify trying to use a loop in this situation. Can you tell why it must have the loop? Maybe there is another way of looking at things.

The help you have been given is free. If you have been happy with our help please consider donating to support this forum.

If you would like to say thanks for the help I have given you please View My Profile and Leave a Comment.
Your encouragement is welcome.

Related Topics



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users