Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Javascript confirm box


  • Please log in to reply
5 replies to this topic

#1 JUICYboy

JUICYboy

  • Members
  • 537 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Anaheim, Ca
  • Local time:09:49 PM

Posted 25 December 2010 - 09:37 PM

Hello everyone,

In javascript pop-up boxes how does the user switch a page. I know that he can click to "accept""cancel" but once he clicks that
how does it take him/her to the next page or whatever. For example in this code pop-ups come up but how are they link to other events once the buttons are clicked?

<html>
<head>
<title>
Confirm boxes
</title>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("Press a button");
if (r==true)
{
alert("You pressed okay!");
}
else
{
alert("You pressed cancel!");
}
}

</script>
</head>

<body>
<input type="button" onclick="show_confirm()" value="show confirm box" />
</body>
</html>

BC AdBot (Login to Remove)

 


#2 CrimsonSpider

CrimsonSpider

  • Members
  • 91 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:The Matrix
  • Local time:01:49 AM

Posted 25 December 2010 - 10:39 PM

Heyy,

Put this after the true statement:

window.location = "abc"

Replacing abc with the url!

Let me know if it works!

CrimsonSpider
"Don’t worry if it doesn’t work right. If everything did, you’d be out of a job."
(Mosher’s Law of Software Engineering)

#3 JUICYboy

JUICYboy
  • Topic Starter

  • Members
  • 537 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Anaheim, Ca
  • Local time:09:49 PM

Posted 26 December 2010 - 03:47 PM

Okay thank-you

What does it do?

After the (r=true)here??

or inside the brackets (r=true "here??")

I am still learning all of this
thanks

#4 CrimsonSpider

CrimsonSpider

  • Members
  • 91 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:The Matrix
  • Local time:01:49 AM

Posted 26 December 2010 - 04:06 PM

Try after the open brace after true:

<script type="text/javascript">
function show_confirm()
{
var r=confirm("Press a button");
if (r==true)
{
window.location = "abc" <---- HERE
alert("You pressed okay!");
}

It should redirect the person to a web page of your choice! :)

Hope i helped,

CrimsonSpider
"Don’t worry if it doesn’t work right. If everything did, you’d be out of a job."
(Mosher’s Law of Software Engineering)

#5 JUICYboy

JUICYboy
  • Topic Starter

  • Members
  • 537 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Anaheim, Ca
  • Local time:09:49 PM

Posted 29 December 2010 - 09:11 PM

Yes Thank-you

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:49 PM

Posted 30 December 2010 - 10:54 AM

Just a comment on your code...

if ( r == true )
is redundant. r already is either true of false, so if( r ) means exactly the same thing. The statement if ( r == true ) is really saying "if true equals true".

Edited by groovicus, 30 December 2010 - 10:54 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users