473,388 Members | 989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Bookmark on Firefox

Hi, this simple code works well to add a bookmark on IE, but it
doesn't work on Firefox
<a href="javascript:window.external.AddFavorite('http ://
www.mysite.com','My site is cool');">

Can someone suggest me something ?

May 5 '07 #1
5 5315
// Firefox 1.x+, IE4+ and Opera7+

<script type="text/javascript">
<!-- // Begin
function bookmarksite(title,url){
if (window.sidebar) // Firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // Opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all) // IE
window.external.AddFavorite(url, title);
}
// End -->
</script>

<a href="javascript:bookmarksite('Page Title',
'http://www.example.com')">Bookmark this site!</a>
Pipp wrote:
Hi, this simple code works well to add a bookmark on IE, but it
doesn't work on Firefox
<a href="javascript:window.external.AddFavorite('http ://
www.mysite.com','My site is cool');">

Can someone suggest me something ?
May 5 '07 #2
Mad Joe said the following on 5/5/2007 3:36 PM:
// Firefox 1.x+, IE4+ and Opera7+
And broken in many of those and others.
<script type="text/javascript">
<!-- // Begin
Remove the worthless, non-working, useless comments.
function bookmarksite(title,url){
if (window.sidebar) // Firefox
While Firefox may support sidebar, it may not be the only browser that
does. But, at least this branch of the if half tests for what you are using.
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // Opera
Is there a browser (or even a version of Opera) that doesn't support
window.print? And, why aren't you testing for what you really want to use?
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all) // IE
IE is far from the only browser that will enter this branch. AOL, for
one, will pass that test but utterly error out on the call to
window.external, and, there is *no* way to add a favorite in AOL via
scripting.
window.external.AddFavorite(url, title);
}
// End -->
</script>

<a href="javascript:bookmarksite('Page Title',
'http://www.example.com')">Bookmark this site!</a>
What happens if scripting is disabled? And, what happens, in IE, when an
animated gif is on the page? (Test it).

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 5 '07 #3
On Firefox this opens the bookmark on the sidebar, how to open it on
the main window ?

On 5 Mag, 21:36, Mad Joe <M...@Joe.netwrote:
// Firefox 1.x+, IE4+ and Opera7+

<script type="text/javascript">
<!-- // Begin
function bookmarksite(title,url){
if (window.sidebar) // Firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // Opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();}

else if(document.all) // IE
window.external.AddFavorite(url, title);}

// End -->
</script>

<a href="javascript:bookmarksite('Page Title',
'http://www.example.com')">Bookmark this site!</a>

Pipp wrote:
Hi, this simple code works well to add a bookmark on IE, but it
doesn't work on Firefox
<a href="javascript:window.external.AddFavorite('http ://
www.mysite.com','Mysite is cool');">
Can someone suggest me something ?- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -

May 6 '07 #4
Randy Webb wrote:
Remove the worthless, non-working, useless comments.
I'm hiding it because of the stupid W3C validators...
While Firefox may support sidebar, it may not be the only browser that
does. But, at least this branch of the if half tests for what you are
using.
Is there a browser (or even a version of Opera) that doesn't support
window.print? And, why aren't you testing for what you really want to use?
IE is far from the only browser that will enter this branch. AOL, for
one, will pass that test but utterly error out on the call to
window.external, and, there is *no* way to add a favorite in AOL via
scripting.
Ask Frankyboy: http://www.dynamicdrive.com/dynamicindex9/addbook.htm
What happens if scripting is disabled? And, what happens, in IE, when an
animated gif is on the page? (Test it).
What if somebody plugs our visitor's ass on 220V and torture him to
death while another jerk is recording the whole event for publishing on
YouTube? Maybe we should build a script which could prevent that sick
possibility to avoid the mess with the law.
May 7 '07 #5
Mad Joe said the following on 5/6/2007 8:18 PM:
Randy Webb wrote:
>Remove the worthless, non-working, useless comments.

I'm hiding it because of the stupid W3C validators...
The validators are stupid but what does that say of one who uses
something they know to be stupid? Search the archives for my name and
"validator" to get some idea of my thoughts about validators.
>While Firefox may support sidebar, it may not be the only browser that
does. But, at least this branch of the if half tests for what you are
using.
Is there a browser (or even a version of Opera) that doesn't support
window.print? And, why aren't you testing for what you really want to
use?
IE is far from the only browser that will enter this branch. AOL, for
one, will pass that test but utterly error out on the call to
window.external, and, there is *no* way to add a favorite in AOL via
scripting.

Ask Frankyboy: http://www.dynamicdrive.com/dynamicindex9/addbook.htm
Why? "Frankyboy" didn't post that crap code to c.l.j., you did. And that
is what is is - crap code. I simply pointed out a few of the flaws in
code that you posted here.
>What happens if scripting is disabled? And, what happens, in IE, when
an animated gif is on the page? (Test it).

What if somebody plugs our visitor's ass on 220V and torture him to
death while another jerk is recording the whole event for publishing on
YouTube?
The difference is that the scenario I asked about is likely to happen
and very simple to work around. Yours won't ever happen. And, I didn't
make my up out of my visitor's ass with 220V connected to it.

The solution is simple. Don't use a javascript: pseudo-protocol. Don't
want your link breaking if JS is disabled? Simple, have JS create the
element to start with.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 7 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Timothy Wu | last post by:
Hi, I'm trying to parse FireFox bookmark files manually using regular expressions. I tried to match key-value pairs in tags like the following: matches = re.findall(r'(\S+)="(.+)"', text) ...
1
by: nkparimi | last post by:
Hi, I wanted to write a script that'd add the current URL to the user's list of bookmarks (Favorites). I found the following script which works for IE: document.write ('' +'<a...
2
by: Thelma Lubkin | last post by:
With Me!PERSONSLIST.Form.RecordsetClone .FindFirst strID If .NoMatch Then Debug.Print "key " & Key & " nomatch" Exit Sub Else If Me.Dirty Then Me.Dirty = False Debug.Print "A_LOAD bookmark = "...
6
by: Chris | last post by:
I have been learning C and want to write a program and need someone to point me in the write direction. I want to write a program to store all my webpage bookmarks in possibly one file. I want it...
0
by: Supra | last post by:
what control is bookmark manager.....it is listview control?.....the one is shown bookmark manager from netscape or firefox webbrowser. if u selected second header's column, so u can move second...
1
by: Cat | last post by:
Hello, maybe someone can help me here.. I was looking for a bookmark script to implement on my website. Actually I always thought such scripts are pretty obsolete but I do have a frame page...
1
by: quushich | last post by:
Hi all... Is there special code to add a "Bookmark this page" link to a mobile page for use on mobile devices? Or are there too many variances in mobile phones to have a set code? I found...
23
by: Stanimir Stamenkov | last post by:
I want to find out whether the following usage of the "Bookmark" link type is o.k. An example could be seen at <http://www.geocities.com/stanio/more/horoskop.html>. The text is in Bulgarian and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.