AS3将网址加入收藏夹

AS3:

ExternalInterface.call("window.extenal.addFavorite","http://www.qq.com","腾讯首页");//对ie有效,火狐firefox无效

1.如果想不仅对ie有效,同时也增加其他浏览器支持,但有不想另外写js文档来调用,可以用这一段,已知支持:火狐firefox微软IE遨游、,真实验证有效

ExternalInterface.call("function(){"

       "if(document.all){window.external.addFavorite('http://www.qq.com','腾讯');}"+ //支持ie

       "else if(window.sidebar){window.sidebar.addPanel('腾讯','http://www.qq.com'',' ');}"+ //支持firefox

       "else if(window.opera && window.print){return true;}}");

2.目前还不知道怎样支持谷歌chrome浏览器,他的貌似比较特殊,不过是可以通过"ctrl+D"进行快捷添加到收藏夹的,如何用代码完成未知。

3.设为主页还不会,我想也同样可以直接调用js代码来完成,设主页js谁会告我~?!

 

------------------------------------------------------------- 以下参考自网络:

AS2:

设置首页: 

btn.onRelease{ 
geturl("javascript :document.body.style.behavior=\"url(#default#homepage)\";document.body.sethomepage(\http://www.actionscript8.com \)", "_self"); 
}

 

加入收藏夹: 

btn.onRelease{ 
geturl("javascript :window.external.addfavorite(\"http://www.actionscript8.com\")", "_self"); 
}

================

JS:

<script type="text/javascript"> 
function addCookie() 
{ 
if (document.all) 
{ 
window.external.addFavorite('http://www.jb51.net','脚本之家'); 
} 
else if (window.sidebar) 
{ 
window.sidebar.addPanel('脚本之家', 'http://www.jb51.net', ""); 
} 
} 
function setHomepage() 
{ 
if (document.all) 
{ 
document.body.style.behavior='url(#default#homepage)'; 
document.body.setHomePage('http://www.jb51.net'); 
} 
else if (window.sidebar) 
{ 
if(window.netscape) 
{ 
try 
{ 
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
} 
catch (e) 
{ 
} 
} 
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch); 
prefs.setCharPref('browser.startup.homepage','http://www.jb51.net'); 
} 
} 
</script> 
<form> 
<a href="#" οnclick="return setHomepage();">设为首页</a> 
<a href="#" οnclick="return addCookie();">添加收藏</a> 
</form>

===========================================================

<script>
function AddFavorite(sURL, sTitle)
{
try
{
window.external.addFavorite(sURL, sTitle);
}
catch (e)
{
try
{
window.sidebar.addPanel(sTitle, sURL, “”);
}
catch (e)
{
alert(”加入收藏失败,请使用Ctrl+D进行添加”);
}
}
}
function SetHome(obj,vrl){
try{
obj.style.behavior=’url(#default#homepage)’;obj.setHomePage(vrl);
}
catch(e){
if(window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege(”UniversalXPConnect”);
}
catch (e) {
alert(”此操作被浏览器拒绝!\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]设置为’true’”);
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref(’browser.startup.homepage’,vrl);
}
}
}
</script>

<a href=”javascript:void(0);” title=”每天上网第一时间打开本站” target=”_self” οnclick=”SetHome(this,’http://vod.kprw.net/’)”>设为首页</a>

<a href=”javascript:void(0);” title=”将本站加入浏览器收藏夹” target=”_self” onClick=”javascript:AddFavorite(’http://vod.kprw.net/’,'开平人影院|开平电影网’)” >收藏本站</a>

收藏功能在Chrome和FireFox都生效,设为主页功能在Chrome和FireFox下提示其他方法设置,感觉不错,改了一改,放出来!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值