日期:2014-05-20  浏览次数:20528 次

刚才重定向问题已结贴,再开一贴求加载前重定向
打开right.aspx?id=361后,在网页加载前实现重定向到主框架页面index.aspx?pid=361     请问,1.如何实现加载前重定向,2.如何获取right.aspx的id参数传递到Index.aspx的pid参数?
在 <head> </head> 间加入如下代码后没反应,只有Onload事件才触发,但是onload是加载完成后触发
function   InFrames(p)
{
        if(window.top.location.toString().indexOf( "index.aspx ")   ==   -1)
        {
                window.top.location.href   =   "index.aspx?pid= "+p;
        }
} </script>

------解决方案--------------------
<head> </head> 之间
<script>
function GetQueryString(name)
{
var reg = new RegExp( "(^|&) "+ name + "=([^&]*)(&|$) ");
var r = window.location.search.substr(1).match(reg);
if(r!=null)
return unescape(r[2]);
return null;
}
var par = GetQueryString( 'id ');
function InFrames()
{
if(window.top.location.toString().indexOf( "index.aspx ") == -1)
{
window.top.location.href = "index.aspx?pid= "+par;
}
}
InFrames(); //直接执行.
</script>

------解决方案--------------------
在Body前执行Js即可