日期:2014-05-18  浏览次数:20563 次

js 怎么重定向到其他项目下的页面
页面用js重定向到其他项目下的页面怎么做的,用location的话,只能是在本项目下跳转,跳不出去。
比如说我的项目地址 http://localhost:8080/helloword/index.html?world=china,我想进入index.html页面的时候,跳转到百度首页(http://www.baidu.com),并且把world=china,参数带到百度首页,这个JS怎么做呢?
js 重定向

------解决方案--------------------
Url.prototype =
{
    getvalue: function(para)
    {
        return this.paraMap.get(para);
    }
}


function Url(urlstr)
{
    this.paraMap = new Map();

    if (urlstr.indexOf('?') > -1)
    {
        urlstr = urlstr.substr(1);
    }
    if (urlstr.indexOf('&') > -1)
    {
        var pvarr = urlstr.split('&');
        for (var i = 0; i < pvarr.length; i++)
        {
            var pv = pvarr[i].split('=');
            this.paraMap.put(pv[0], pv[1]);
        }
    }
    else
    {
        var pv = urlstr.split('=');
        this.paraMap.put(pv[0], pv[1]);
    }
}