今天遇到一个奇葩的问题,使用window.location.href实现页面跳转的时候,跳转的是相对地址。
(说明:我们是在机顶盒上写的页面,所以都是处理的遥控器的key)
<a οnfοcus="" href="setting.html" οnkeydοwn="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 οnkeydοwn="netSet(event);" οnfοcus="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 οnfοcus="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";
}