[Javascript] Need Javascript logic for going to homepage if the previous history not available

Rajaram Sahasranaman rajarsn at gmail.com
Fri Aug 29 21:39:08 CDT 2008


Hi,

In my aspx page, I have two tabs. I have written a javascript in such a way
that if the user clicks on first tab, it will go to the previous page
visited and that will be the required behaviour which is working perfectly
fine.

Sometimes the previous history will not be available. In the sense, there is
an option that the user can directly visit the page by making changes in the
url without going to login and home page. In such a case, I need to show the
user the home page. How will I do that? Can anybody provides any logic to me
for this?

I have used the following JS code for going to previous page.
function UltraWebTabMain_Click(oWebTab,oTab,oEvent)
{
var wTab = igtab_getTabById("ctl00_TabControl1_UltraWebTab1");
if(wTab!=null)
{
var tab = wTab.getSelectedTab();
if(tab!=null)
{
var tabtext = tab.getText();
var FirstTab = 0;
if ((oTab.Key == "Search") && (tabtext != "Search"))
{
window.history.go(-1);
wTab.setSelectedIndex(FirstTab);

}

}
}
}

Can I do any modification to the above JS code so that the user should be
directed to Home Page if history not present? Can anybody provide any help
please?

Thanks
Meeram395[image: Smile]



More information about the Javascript mailing list