现在的位置: 首页 > 综合 > 正文

搞定跳转页面location用法 (转载)

2011年07月30日 ⁄ 综合 ⁄ 共 919字 ⁄ 字号 评论关闭

转载自 仰天一笑
先前写了一片用window.location.href实现刷新另个框架页面 ,现在我将他整理成全部的js功能,方便查阅
具体如下:
//简单跳转
function gotoPage(url)
{
// eg. var url = "newsview.html?catalogid="+catalogID+"&pageid="+pageid;
window.location = url;
}
// 对location用法的升级,为单个页面传递参数
function goto_catalog(iCat)
{
if(iCat<=0)
{
top.location = "../index.aspx"; // top出去
}
else
{
window.location = "../newsCat.aspx?catid="+iCat;
}
}
// 对指定框架进行跳转页面,三种方法皆可用
function goto_iframe(url)
{
// parent.document.getElementById("mainFrame").src = "../index.aspx";// use dom to change page
//parent.mainFrame.location="../index.aspx"; // use location to change page
parent.mainFrame.location = "../index.aspx"; //
}
// 对指定框架进行跳转页面
function goto_iframe(iframename,url)
{
parent.document.getElementById(iframename).src = "../index.aspx";// use dom to change page by iframeName

//因为 parent.iframename.location="../index.aspx"; 方法不能实行,主要是 "parent.iframename" 中的iframename在js中被默认为节点,而不能把传递过来的参数转换过来,所以用dom实现比较方便
}
// 回到首页
function gohome()
{
top.location = "/index.aspx";
}
</script>

抱歉!评论已关闭.