最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
javascript兼容ie,ff设置首页,加入收藏代码
时间:2011-01-12 编辑:简简单单 来源:一聚教程网
如果要兼容多浏览器就要判断用户的浏览器类型,如果是firefox还是ie6,7,8等,这样可以根据他们不能的区别进行判断再作操作。
无标题页
简单代码
//添加到收藏夹
function addtofavorite()
{
if (document.all){
window.external.addfavorite(document.url,document.title);
}else if (window.sidebar){
window.sidebar.addpanel(document.title, document.url, "");
}
}//设为首页
function sethomepage(){
if (document.all){
document.body.style.behavior='url(#default#homepage)';
document.body.sethomepage(document.url);
}else if (window.sidebar){
if(window.netscape){
try{
netscape.security.privilegemanager.enableprivilege("universalxpconnect");
}catch (e){
alert( "该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );
}
}
var prefs = components.classes['@mozilla.org/preferences-service;1'].getservice(components. interfaces.nsiprefbranch);
prefs.setcharpref('browser.startup.homepage',document.url);
}
}
调用方法
-
下一个: javascript中常用的日期函数
相关文章
- ipad怎么调静音 ipad消息通知静音设置 04-29
- Galaxy MEGA如何设置静止IP?(I9200,I9152) 07-24
- javascript cookes 设置路径方法 12-14
- javascript 设置背景透明效果代码 06-09
- HTML简单购物数量小程序代码展示 10-31
- html canvas实现弹幕功能 10-31