Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
<!DOCTYPE html>
<html>
<body>

<p>Click the button to display a confirm box.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction()
{
var x;
var r=confirm("Press a button!");
if (r==true)
  {
  window.Location="http://www.yahoo.com";
  }
else
  {
  x="You pressed Cancel!";
  }
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>



can i redirect on the ok buton press???
if yes then how?


if no then plz give me another way to show popup in my aspx page and on press ok button need to open another page


plz help me out>...
Posted

hi, replace this script
JavaScript
 <script>
        function myFunction() {
            var x;
            var r = confirm("Press a button!");
            if (r == true) {
                location.href = "http://www.yahoo.com";
            }
            else {
                x = "You pressed Cancel!";
            }
            document.getElementById("demo").innerHTML = x;
        }
</script>
no need to write a server side code here :P
 
Share this answer
 
v2
Comments
prince_rumeel 4-Oct-12 5:34am    
bro i want to show new page such like here u can see yahoo page link.
but it is not opening it
tanweer 4-Oct-12 5:43am    
i tested it and it is redirecting to yahoo.com. do you want to open it in a new tab or window???
prince_rumeel 4-Oct-12 5:46am    
yes i want to open it in a new window.or u can say in a new tab
prince_rumeel 4-Oct-12 6:19am    
can we call our java script function from code behind???

and plz help me can i change the title of this confermation box.
recently it is displaying
The Page At LocalHost says:

i dont wana use this title i want to use my own title.
how can i do this?
tanweer 4-Oct-12 6:50am    
change location.href = "http://www.yahoo.com";
to
window.open('http://www.yahoo.com' ,'_blank');

for your 2nd requirement you should use 3rd party controls like telerik
use the following in your function! instead of window.location();
C#
response.redirect("www.yahoo.com")
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900