日期:2014-05-17  浏览次数:20518 次

添加到收藏夹中的功能在用手机访问该网页时不起作用,该怎么解决
我用如下脚本,在PC上使用没有问题,但是使用手机访问时,不起作用(浏览器为Oprea),该如何解决
onclick="window.external.addFavorite.......

------解决方案--------------------
不同的浏览器做法不同
参见

<script type="text/javascript">
// < ![CDATA[
function bookmark(){
var title=document.title;
var url=document.location.href;
if (window.sidebar){//firefox
window.sidebar.addPanel(title, url,"");
}else if(window.opera){//opera
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();
}else if(window.external){//ie
window.external.AddFavorite(url, title);
}else{
alert('Unfortunately, your browser does not support this action,please bookmark this page manually by pressing Ctrl + D on PC or Cmd + D on Mac.');
}
}
// ]]>
</script>