Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to navigate based on confirm answer 1

Status
Not open for further replies.

muru

MIS
May 21, 2003
5
US
Hi,
I am trying to figure out how to navigate through frames based on confirmation result. In my left frame I have a list of link, now if I click on a link I use a javascript function to ask for confirmation from the user if he actually wants to leave the current page. If the user choose yes, I populate the link in the right frame, if not I leave the right frame alone where it was. Now I am able to to the first part of this but I am unable to achieve the second part. Can some one shed some light on this. Below is javascript function that I am using.

function confirmPDRSearch()
{
var ans = confirm ("Are you sure you want to navigate away from this page?");
if(ans==true)
{
window.SideBar.target = "SearchPDR.aspx";
}
else
{
(I don't know how to handle the else part)
}
}


Thank you,
Muru
 
To do nothing, simply remove the "else {}"... so:

Code:
function confirmPDRSearch() {
   var ans = confirm('Are you sure you want to navigate away from this page?');
   if(ans) window.SideBar.target = 'SearchPDR.aspx';
}

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
OK, then what would I declare in the HREF section for the link.....

<A HREF="SearchPDR.aspx" target="mainwindow" onclick ="confirmPDRSearch()">Search PDR</A>

Can I leave it blank and let the function decide on the URL?
 
How about this instead:

Code:
function confirmPDRSearch() {
   return(confirm('Are you sure you want to navigate away from this page?'));
}

...

<a href="SearchPDR.aspx" target="mainwindow" onclick="return(confirmPDRSearch());">Search PDR</a>

You can use the same function call for all the links that way.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
thank you very much. it helped a lot.


bye,
muru
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top