PDA

View Full Version : [DHTML] Modified Bookmark Site script



frankyboy
02-08-2007, 04:00 PM
1) CODE TITLE: Modified Bookmark Site script

2) AUTHOR NAME/NOTES: Dynamic Drive modified by Francois Lavertu

3) DESCRIPTION: Modified version of the Bookmark Site script http://www.dynamicdrive.com/dynamicindex9/addbook.htm to support Opera (version 9 tested)

4) URL TO CODE:

or, ATTACHED BELOW (see #3 in guidelines below):

jscheuer1
02-08-2007, 04:10 PM
Works! Give that coder a gold star.

frankyboy
02-08-2007, 04:41 PM
My webserver is down so here's the code



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test</title>
<script type="text/javascript">
/***********************************************
* Bookmark site script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera (v9 tested) */
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);
}
</script>
</head>

<body>
<a href="javascript:bookmarksite('Yahoo', 'http://www.yahoo.com');">Bookmark Yahoo</a>
</body>
</html>

mburt
02-08-2007, 10:17 PM
Wow... I didn't even know that script could be cross-browser. Good work.

ddadmin
02-08-2007, 10:51 PM
Indeed, nice and short too! Updated script (http://www.dynamicdrive.com/dynamicindex9/addbook.htm) to include the change. Thanks,

jscheuer1
02-08-2007, 11:04 PM
Indeed, nice and short too! Updated script (http://www.dynamicdrive.com/dynamicindex9/addbook.htm) to include the change. Thanks,

Yay!!!

mburt
02-08-2007, 11:10 PM
Wow, John. You're freakishly happy today :p

ddadmin
02-09-2007, 12:34 AM
I'll have what John's having please...

jscheuer1
02-09-2007, 03:48 AM
I'll have what John's having please...

That would be a cup of Earl Grey. A pot, er several pots, rather -some high end distressed bread (Pane Rustico - a 'Rustic and Chewy Peasant Bread with a Lightly Sour Flavor'). Those peasants really know how to live. And, you missed dinner here. If you like spicy food, you would probably have enjoyed my own recipe shoulder cut lamb chops.

I am often amused and a little concerned that whenever I act a little silly around the forums, I feel as though others imagine I must be using some drug or drinking alcohol.

Many years ago I volunteered at a rehab center. They asked me to tone it down or stop coming because all the recovering addicts thought I was high. So, you folks are not alone. Comfortingly though, the people running the center could tell the difference.

Believe me, I have been sober in about the strictest sense of the term for over two years (I had a glass of champagne for New Years). That is if you exclude one's state of mind.

But, don't mess with my internet connection, I might go into withdrawal.

Schatana
02-09-2007, 11:42 PM
First off, thank you a lot for the script!

I have just one little question - is there a way to avoid that bookmarked pages in Mozilla will be opened in the sidebar?

I tried all I could but I'm just hopeless with javascript.

My problem is I have a frame site and many of my users have trouble bookmarking the subpages. The subpages can be loaded each one for itself within its frameset (like index.html?subpage) but my visitors do not seem to get it. They click 'bookmark' in their browser and end up with the main frameset instead.

So I was happy to find your script working on both Mozilla and IE - when your script bookmarks the subpage just perfectly - if only the sidebar wouldn't come in..

Is there anything I could do to avoid the sidebar thing?

Thanks again, and I hope you do not mind my question..

Catherina

Gephri
02-15-2007, 06:34 PM
I've got the same problem/question:
is there a way for Mozilla bookmarked pages to open in the main screen rather than the sidebar?

Revelation 888
04-13-2007, 07:01 PM
This script works in Opera v9.10 but has anyone had troubles in opera v9.20, I can't seem to get it working

tweakerxp
04-15-2007, 12:47 AM
I've got the same problem/question:
is there a way for Mozilla bookmarked pages to open in the main screen rather than the sidebar?

Yeah, I've got the same problem. Anyone have any ideas?

Roger Huston
05-09-2007, 07:01 AM
Hello,

How do I modify the code so that the page does NOT load in FF's Side BAR? Every time I use the code, the "Load this bookmark in the sidebar" is checked. I do not want that. How do I turn that off?

Thanks,

-Roger

Peikel
05-14-2007, 10:21 AM
Hello,

I guess there's still no solution to the Firefox/sidebar problem?
Thanks for the script anyway!

Pei

towleroad
06-20-2007, 09:29 AM
is there any reason it wouldn't be mentioned on the download page? Anyone have a fix for it?

pjrobertson123
06-23-2007, 06:10 PM
I can confirm what Revelation 888 said
This doesn't work in Opera >9.2 (I'm using 9.21) It just takes you to the 'bookmark' page as a link

chornee
10-17-2007, 02:18 PM
Still no solutions for the sidebar thing ? I dont use any frames or anything and it uses the side bar, almost makes it worse than it not working in Firefox :(

Anyone got any ideas on a work around for this ?

jscheuer1
10-17-2007, 04:09 PM
I can confirm what Revelation 888 said
This doesn't work in Opera >9.2 (I'm using 9.21) It just takes you to the 'bookmark' page as a link

I didn't write this script and don't particularly like the 'bookmark this' concept, the browser already has that capability. Each browser does it differently, and not all browsers expose this capability to javascript as fully as does IE. This result in Opera seems adequate to me.


Still no solutions for the sidebar thing ? I dont use any frames or anything and it uses the side bar, almost makes it worse than it not working in Firefox :(

Anyone got any ideas on a work around for this ?

See above. In FF the same basic concept holds, it does however expose the sidebar bookmark to scripting. This is an acceptable fall back, but if you want it to do nothing in FF, just replace the code for FF with:

return;


<script type="text/javascript">
/***********************************************
* Bookmark site script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera (v9 tested) */
function bookmarksite(title,url){
if (window.sidebar) // firefox
return;
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);
}
</script>

It would also be a nice touch to script the link. Change this:


<a href="javascript:bookmarksite('Yahoo', 'http://www.yahoo.com');">Bookmark Yahoo</a>

to:


<script type="text/javascript">
if(document.documentElement.filters||window.opera)
document.write('<a href="javascript:bookmarksite(\'Yahoo\', \'http://www.yahoo.com\');">Bookmark Yahoo</a>');
</script>

That way only IE and Opera will see it.

chornee
10-17-2007, 04:49 PM
I dont think people want it to do nothing :) the question was more if there is any way possible for it to work correctly. But it doesnt look like there is.

O well, I dont see why the only way to do it in Firefox is in the sidebar, thats just stupid.

jscheuer1
10-17-2007, 05:09 PM
I dont think people want it to do nothing :) the question was more if there is any way possible for it to work correctly. But it doesnt look like there is.

O well, I dont see why the only way to do it in Firefox is in the sidebar, thats just stupid.

What people?

chornee
10-17-2007, 06:13 PM
The other people on this thread that posted the same questions. ANd probably every other person who has a bookmark this site button and it doesnt work in Firefox

jscheuer1
10-17-2007, 06:16 PM
The other people on this thread that posted the same questions. ANd probably every other person who has a bookmark this site button and it doesnt work in Firefox

I have little sympathy. FF, as well as other browsers are perfectly capable of bookmarking sites. If someone wants to bookmark a site, they will do it themselves.

chornee
10-17-2007, 06:43 PM
That wasnt the question hah. The question is how to do it, not why you wouldnt care if it can be done. A Bookmark us button is something thats there to kinda remind and encourage users to click it to add to favorites. Obviously there are other ways to do it.


Well if anyone ever finds a way to actually accomplish this please post.

jscheuer1
10-17-2007, 08:18 PM
That wasnt the question hah. The question is how to do it, not why you wouldnt care if it can be done. A Bookmark us button is something thats there to kinda remind and encourage users to click it to add to favorites. Obviously there are other ways to do it.


Well if anyone ever finds a way to actually accomplish this please post.

I did address the question of yours that I initially responded to:


makes it worse than it not working in Firefox :(

Anyone got any ideas on a work around for this ?

I believe my reasoning on being unenthusiastic about the script's objectives to be very sound.

As far as I know, which is considerable in this area - though I am always willing to learn more, there is no other way to javascript a bookmark in FF.

molendijk
10-21-2007, 07:16 PM
Catherina (Schatana) asked a question about the bookmarking script, that puts the bookmarked pages in the sidepanel (FF).

Perhaps I found some sort of solution (for frame sites). On my (frame) sites, I put a very visible bookmark button in top.html. When the user clicks on the button, the URL in the address bar is forced to adapt itself to the name of the main frame's page that the user is actually viewing. After that, an alert tells the user what to do, depending on the browser: CTRL + D, or ALT + F, etc.

There is a demo here (http://www.dynamicdrive.com/forums/showthread.php?t=25009&highlight=molendijk).

(I didn't start that thread for the sake of bookmarking, but to show that you can have layers on top of a frameset).

Arie Molendijk.

SmittyMeista
01-24-2009, 10:31 AM
This is pretty much exactly what I've been looking for...

One question - other browsers - Safari, for example. What happens there?

diltony
01-24-2009, 10:14 PM
That rocks!

I think u should check google first like http://www.google.com.ng/search?hl=en&q=how+to+resize+images+with+php&btnG=Google+Search&meta=
If you are still havin problems, lemme know - the script is quite easy, but if u do not understand it - u may still hav problems.
If u still have problems, describe to me precisely wat u need so i can modify my own script for you - i have a lot of resizin scripts for various purposes.

WycheGnome
05-15-2012, 07:03 AM
Have just put this script into use on http://www.s-r-s.org.uk/

Works ok in IE but there is a quirk in Firefox. Initially the link does not work but it does kick in once the user has run their mouse over the links in the navigation panel! The user doesn't have to select anything, just run the mouse over the area.

Any thoughts anyone?

John