Firefox的JavaScript书签问题 [英] A Firefox javascript bookmarking problem

查看:114
本文介绍了Firefox的JavaScript书签问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的JavaScript代码:

 < script language =JavaScript1.2type =text / JavaScript的> 
函数CreateBookmarkLink(title,url){
if(window.sidebar){
window.sidebar.addPanel(title,url,);
} else if(window.external){
window.external.AddFavorite(url,title); }
else if(window.opera& window.print){
return true; }
}
< / script>

这将为Firefox和IE创建书签。但是Firefox的链接将显示在浏览器的侧面,而不是显示在主屏幕上。我个人觉得这非常讨厌,我正在寻找更好的解决方案。当然可以手动编辑书签使其不在侧面板上显示,但需要额外的步骤。我只是希望能够让人们以简单的方式将网页加入书签(在用于构建特定方案的网址中有很多GET信息)。



恐怕Firefox可能无法在主屏幕上显示该页面(因为谷歌搜索这个主题几乎没有什么值得使用的),但我可能错过了一些东西。如果有人有一个想法,如果这是可能的,或者如果有一个解决方法,我很乐意听到这件事。

我认为这是Firefox的唯一解决方案...我有一个更好的功能,即使对于Opera,并显示其他不支持的浏览器的消息。

 < script type =text / javascript> 
函数addBookmark(url,name){
if(window.sidebar&& window.sidebar.addPanel){
window.sidebar.addPanel(name,url,''); //从FF 23废弃。
} else if(window.opera& window.print){
var e = document.createElement('a');
e.setAttribute('href',url);
e.setAttribute('title',name);
e.setAttribute('rel','sidebar');
e.click();
} else if(window.external){
try {
window.external.AddFavorite(url,name);



$ b alert(要将我们的网站添加到您的书签,请在Windows和Linux上使用CTRL + D,Command + D在Mac上);
}
< / script>


I'm using the following JavaScript code:

<script language="JavaScript1.2" type="text/javascript">
 function CreateBookmarkLink(title, url) {
    if (window.sidebar) {
        window.sidebar.addPanel(title, url,"");
    } else if( window.external ) {
        window.external.AddFavorite( url, title); }
    else if(window.opera && window.print) {
        return true; }
 }
</script>

This will create a bookmark for Firefox and IE. But the link for Firefox will show up in the sidepanel of the browser, instead of being displayed in the main screen. I personally find this very annoying and am looking for a better solution. It is of course possible to edit the bookmark manually to have it not show up in the side panel, but that requires extra steps. I just want to be able to have people bookmark a page (that has a lot of GET information in the URL which is used to build a certain scheme) the easy way.

I'm afraid that it might not be possible to have Firefox present the page in the main screen at all (as Googling this subject resulted in practically nothing worth using), but I might have missed something. If anyone has an idea if this is possible, or if there's a workaround, I'd love to hear about it.

解决方案

I think that's the only solution for Firefox... I have a better function for that action, it works even for Opera and shows a message for other "unsupported" browsers.

<script type="text/javascript">
function addBookmark(url,name){
    if(window.sidebar && window.sidebar.addPanel) {
        window.sidebar.addPanel(name,url,''); //obsolete from FF 23.
} else if(window.opera && window.print) { 
        var e=document.createElement('a');
        e.setAttribute('href',url);
        e.setAttribute('title',name);
        e.setAttribute('rel','sidebar');
        e.click();
} else if(window.external) {
        try {
            window.external.AddFavorite(url,name);
        }
        catch(e){}
}
else
        alert("To add our website to your bookmarks use CTRL+D on Windows and Linux and Command+D on the Mac.");
}
</script>

这篇关于Firefox的JavaScript书签问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆