Firefox compatible Bookmark script?

Uncle Marky

Fledgling Freddie
Joined
Mar 5, 2006
Messages
11
This might be of use to someone. Not my own work - yeah yeah I know it never is - but I have converted it :) . Works with Firefox and Opera as far as I know.

Uploaded a bookmark.js file to the root of my site. The code of which is this:

Code:
function AddBookmark()

{

	title="MKJsWorld";

	url="http://mkjsworld.com";



	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;

	}

}



if (window.external)

{

	document.write('<a href="javascript:AddBookmark()");"></a>');

}

else if (window.sidebar)

{

	document.write('<a href="javascript:AddBookmark()");"></a>');

}

else if (window.opera && window.print)

{

	document.write('<a href="javascript:AddBookmark()");"></a>');

}

Then created a link to operate above:

Code:
<script type="text/javascript" src="bookmark.js"></script><a href="javascript:AddBookmark()" )="">Bookmark</a>

If you need to then use a full url instead of just bookmark.js so that the link locates the file.

Have fun!
 

JingleBells

FH is my second home
Joined
Mar 25, 2004
Messages
2,224
If i want to bookmark a site, I usually goto "Bookmarks -> Bookmark this page" or press Ctrl-D, rather than using a load of js that just adds to download times.

There is also a whole load of redundant javascript there, the code should read:
Code:
function AddBookmark() {
	var title="MKJsWorld";
	var url="http://mkjsworld.com";

	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	}

	else if( window.external ) {
		window.external.AddFavorite( url, title);
	}
}

if (window.external || window.sidebar) {
	document.write('<a href="javascript:AddBookmark()");"></a>');
}
 

Uncle Marky

Fledgling Freddie
Joined
Mar 5, 2006
Messages
11
Not another one!

If i want to bookmark a site, I usually goto "Bookmarks -> Bookmark this page" or press Ctrl-D, rather than using a load of js that just adds to download times.

Wow m8y - yu are so erudite. Yu ever consider that 99% of the surfer population know shit? This code isn't for the likes of you is it but people who know sod all. Why does every bugger want to show how intelligent or knowledgeable they are on this forum? You don't get this crap on any other forum.

As for the alterations I just made a few but I will admit I know hardly anything about javascript just enough to get rid of a few errors - such as was occurring on using the script.

Climb off you high horse m8 and consider that most - practically all - surfers just browse and will click on something if it saves time. Code works with Firefox and Opera which is exceptional. Job done.
 

Clown

Part of the furniture
Joined
Dec 22, 2003
Messages
4,292
You're a fucking idiot who's still trying to pimp his own shit site.
 

JingleBells

FH is my second home
Joined
Mar 25, 2004
Messages
2,224
Uncle Marky said:
Code works with Firefox and Opera which is exceptional. Job done.

Except it doesn't work in opera, the js for opera:
Code:
else if(window.opera && window.print)
	{
		return true;
	}
combined with the HTML:
Code:
<a href="javascript:AddBookmark()">Bookmark</a>
(incorrect HTML too, javascript: should not be used, use onkeypress and onclick combined with return false) just writes "true" on my browser screen. (Tested on Opera 8.54)

It does however work in firefox 1.5.0.4 and IE7.
 

Shovel

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,350
Arrgh. Right:

Uncle Marky said:
Wow m8y - yu are so erudite. Yu ever consider that 99% of the surfer population know shit? This code isn't for the likes of you is it but people who know sod all.

Please don't make up statistics. There is a good, debatable point in what you're saying. Pondering how many internet users actually know how to operate their browser and the relative worth of duplicating browser interface within pages is a reasonable subject for discussion in my book. Having that debate would be fine with some real stats to start it off or at least a less confrontational attritute.

Uncle Marky said:
Why does every bugger want to show how intelligent or knowledgeable they are on this forum?

Because this is a forum all about knowledege. It's about sharing knowledge and discussing the best ways to do things when developing web sites and applications. As such, people responding with improvements to your code or playing devils advocate to your premise is part of the game here. The idea is to learn the best way and no-one should ever post here certain that they've already got the best way sussed.

Uncle Marky said:
Code works with Firefox and Opera which is exceptional. Job done.

Except that this forum doesn't have an ethods of ‘that'll do, job done’. If there's optimisation and improvement - especially to something as open ended as a script - you should expect (and welcome) people's contributions.


Also, please give attribution when you've built of the work of an existing script.
 

Users who are viewing this thread

Top Bottom