关于window.location.href跳转绝对地址的问题

来源:互联网 发布:网络教育取消学籍 编辑:程序博客网 时间:2024/05/16 09:42

今天遇到一个奇葩的问题,使用window.location.href实现页面跳转的时候,跳转的是相对地址。

(说明:我们是在机顶盒上写的页面,所以都是处理的遥控器的key)

<a onfocus="" href="setting.html" onkeydown="setti(event);"><img class="big-img" src="images/settings.png" alt="setting"></a>

function setti(e){
        e=window.event||e;
        if(e.keyCode == 13){
            //url = "file://"+callApp('Get_NetSetting_Page');
            //console.log("------------Get_NetSetting_Page="+url);
            window.location.href="www.baidu.com";
        }
    }

以上是可以跳转的。

但是以下这样就不能跳转了:

<a onkeydown="netSet(event);" onfocus="return false;" href="" class="scale-item movies big-cover">
                        <img class="big-img" src="images/net.png" />
                        <div class="wz"><h3>Network Setting</h3></div>
                    </a>

function netSet(){
        //var url = "file://"+callApp('Get_NetSetting_Page');
        //console.log("------------Get_NetSetting_Page="+url);
        window.location.href="www.baidu.com";
    }

最后改成以下这样就可以了,我也不知道为啥:

<a onfocus="return false;" href="javascript:jumpNet();" class="scale-item movies big-cover">
                        <img class="big-img" src="images/net.png" />
                        <div class="wz"><h3>Network Setting</h3></div>
                    </a>

function jumpNet(){
        var url = "file://"+callApp('Get_NetSetting_Page');
        console.log("------------Get_NetSetting_Page="+url);
        window.location.href="www.baidu.com";
    }

0 0
原创粉丝点击