PDA

View Full Version : Add to favorites script



ckirk
07-25-2006, 01:44 PM
I have an "Add this page to your favorites" script on my web site. It works fine in IE, but I can't get it to work in Firefox. If you click the link in Firefox, nothing happens. If I change the tab to IE, but still use Firefox, I get a runtime error message that says, "window.external is null or not an object." Here is the script I am using:

<a href="javascript:window.external.AddFavorite('http://mysite.com','site description')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('b11','','images/buttons/addfav_2.gif',0)"><img src="images/buttons/addfav_1.gif" name="b11" width="139" height="28" border="0"></a>

I have tried using the "bookmark this page" on other sites and can't get theirs to work in Firefox either.

Does anyone have a solution?

ckirk

jscheuer1
07-26-2006, 06:21 AM
You cannot bookmark in FF (and certain similar NS) without the sidebar. This produces a slightly different sort of bookmark that can later be converted to an ordinary bookmark by the user if he or she chooses to do so and knows how. No browsers other than FF (and certain similar NS) and IE can do any sort of javascript driven bookmarks, at least as far as I know. Did you try this script from the DD library:

http://www.dynamicdrive.com/dynamicindex9/addbook.htm

ckirk
07-26-2006, 09:02 PM
Thanks, John. That script provided a workable solution. It works in FF and it works in IE. The only thing you can't do is use it when using the FF extension to view a page in IE and there isn't any reason I can think of why anyone would need to do that.

Thanks again,

ckirk

Saz
01-23-2007, 09:09 PM
You cannot bookmark in FF (and certain similar NS) without the sidebar. This produces a slightly different sort of bookmark that can later be converted to an ordinary bookmark by the user if he or she chooses to do so and knows how. No browsers other than FF (and certain similar NS) and IE can do any sort of javascript driven bookmarks, at least as far as I know. Did you try this script from the DD library:

http://www.dynamicdrive.com/dynamicindex9/addbook.htm

Hi, do you know how to do the code on that link you kindly suggested above, but with the js code in a separate page please ? I've been trying, but can't seem to be able to do it.

Any help appreciated.

Saz.

coothead
01-24-2007, 12:37 PM
Hi there Saz,

and a warm welcome to these forums. ;)

Does this help...
some_page.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>bookmark dynamicdrive forums</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript" src="bookmark.js"></script>

</head>
<body>

<ul>
<li><a class="bookmark" href="http://www.dynamicdrive.com/forums/" title="dynamicdrive forums">dynamicdrive forums</a></li>
<li><a href="http://www.w3schools.com/" title="w3schools">w3schools</a></li>
</ul>

</body>
</html>
boomark.js

window.onload=function() {
anc=document.getElementsByTagName('a');
for(c=0;c<anc.length;c++) {
if(anc[c].className=='bookmark') {
anc[c].onclick=function() {
if(document.all) {
window.external.AddFavorite(this.href,this.title);
}
else {
if(window.sidebar) {
window.sidebar.addPanel(this.title,this.href,'');

}
}
}
}
}
}
coothead

Saz
01-24-2007, 01:28 PM
Many thanks for the help Coothead and thanks also for the warm welcome :)

One thing, which one is better please ?

<script language="JavaScript" type="text/javascript" src="bookmark.js"></script>

<script type="text/javascript" src="bookmark.js"></script>

Saz.

coothead
01-24-2007, 01:37 PM
Hi there Saz,


language="JavaScript" is deprecated and should not be used. ;)

coothead

Saz
01-24-2007, 02:16 PM
Thanks for the quick help on this Coothead - it's appreciated.

Just tried the code you kindly suggested, but when clicking on the link, it doesn't add the site to the favorites in either IE or FF ;-(

http://www.010805.com/favorites/

Saz.

coothead
01-24-2007, 02:31 PM
Hi there Saz,

...but when clicking on the link, it doesn't add the site to the favorites in either IE or FF
the reason for this is that, you have not placed bookmark.js in the same directory as your links page. :eek:
At the moment it is at...

http://www.010805.com/bookmark.js
...whereas your links page is at...

http://www.010805.com/favorites/
Let them get together and it should, hopefully, produce a satisfactory union. ;)

coothead

Saz
01-24-2007, 02:44 PM
Many thanks Coothead - ya don't fancy a job as my guardian angel do you ?

Ok, we're now a step nearer - but when clicking the link, it *does* bring up the add to favs box, *but* it also goes to the page in the link ;-(

http://www.010805.com/favorites/

Also, are you able to apply a hover class to the links at all please ?

Saz.

mburt
01-24-2007, 02:47 PM
That has to do with some CSS coding:

Try this:

<style type="text/css">
a:hover {
/*hover effect here, eg. color:red*/
}
</style>

Saz
01-24-2007, 03:01 PM
Many thanks MBurt - the hover prob is solved.

Just need to solve the prob with the link going off somewhere else ;-(

Saz.


ps. You've got a great site - can you do a spellcheck on the following :

Okay. Big modifications. Site completely redisigned with PHP,

coothead
01-24-2007, 03:06 PM
Hi there Saz,

change this line in the script...

anc[c].onclick=function(){
...to this...

anc[c].onmouseover=function(){
coothead

Saz
01-24-2007, 04:21 PM
Thanks again Coothead.

I did amend the code a little while ago and just seen the code above that you kindly suggested - the code that is on the page is now working - but I'm a comparative newb at js - which code would be better please ? Compatibility and usability fit-for-purpose are the 2 main issues unless there's other issues to think of ?

http://www.010805.com/favorites

The helps appreciated.

Saz.

Switch
09-06-2007, 07:55 AM
Hello,
Can I use this script to add some favorites on a certain page which is included in my website?

What I mean is: if you have a website where the visitor can choose some items,....clicks on it, and it is added to the page where you keep your favorites. (like Ebay for instance......)

What must I change on the mentioned script to get it worked?

Switch.

Don't forget to give. Givers never lack!