PDA

View Full Version : FIREFOX: Set as homepage & add to bookmarks


Ruben
08-13-2004, 11:29 AM
Hello,

My javascript for add to bookmarks and set as homepage doesn't work in firefox, though it does in IE...how come??

Thanks for your time ;)

:rolleyes: - Ruben

tg
08-13-2004, 03:47 PM
well, whats the javascript your using for ie?

Ruben
08-13-2004, 03:54 PM
well, whats the javascript your using for ie?

<script language="JavaScript">
function addtoFavo(){
window.external.AddFavorite('http://www.studiogazal.com','Studio Gazal, Professional graphic design');
}
function setasHome(){
document.body.style.behavior='url(#default#homepag e)';
document.body.setHomePage('http://www.studiogazal.com');
}
</script>

And of course the following in my swf:
getURL("javascript:addtoFavo();");
getURL("javascript:setasHome();");

:confused: - Ruben

tg
08-13-2004, 04:06 PM
try this:
replace these lines:


document.body.style.behavior='url(#default#homepag e)';
document.body.setHomePage('http://www.studiogazal.com');


with:

this.style.behavior='url(#default#homepage)';
this.setHomePage('http://www.studiogazal.com');


and see what happens.

Ruben
08-13-2004, 04:13 PM
Still nothing happened....

:( - Ruben

oliver69
04-14-2005, 04:32 AM
Hi,

try this. should work for IE and firefox:


<script>
function addBookmarkForBrowser() {
if (document.all)
{
window.external.AddFavorite(document.location.href , document.title);
} else {
var ea = document.createEvent("MouseEvents");
ea.initMouseEvent("mousedown",1,1,window,1,1,1,1,1,0,0,0,0,1,null);
var eb = document.getElementsByTagName("head")[0];
eb.ownerDocument getter = new Function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");
eb.dispatchEvent(ea);
}
}
</script>

<a href="javascript:addBookmarkForBrowser();">Add to Favorites</a>


Hope it helps.

Ruben
04-17-2005, 01:00 PM
Hey thanks dude! Am I mistaking or did you just register for the sake of helping me out? Thanks heaps man

:) - Ruben

[Sx]
04-17-2005, 09:23 PM
Who needs those things anyways? I would never click on a button to set my home page or add a bookmark - I keep such features disabled... Nobody's messin with my browser except me! ... If I want to bookmark something, i'll bookmark it faster with ctrl+d than to bother clicking on some links...

Ruben
04-18-2005, 09:54 AM
']Who needs those things anyways? I would never click on a button to set my home page or add a bookmarkNeither would I, CTRL+D for president. But hey, remember to always think about the ways of your target-audience first; stupid Lizzy from down the street who bumped into the site incidentally might click the bookmark-link. In 4 years maybe she'll need some proper webdesign for the hairdresser's saloon she started...

:) - Ruben

AFemaleProdigy
09-12-2006, 03:23 AM
I have seriously tried the three variations that I could find on this site for setting the current page as "Home Page", but none of them have worked thus far. I can't seem to find a current post about this either. Can someone please help me out with this. Maybe tell me where I am going wrong. I would post the code I have been using, but it's exactly what was listed here and also attempted what was listed in other threads. I managed to get the bookmark property to work, but not the "Set As Home Page" property. Anyone care to shed some light on this? Pleeeease? :)

soonguy
10-23-2006, 05:04 PM
Are you saying you got this script to work, so that you get a bookmark link that works in IE or FF?

I can't get this to work in either :-(

Best wishes

Tony

AFemaleProdigy
10-23-2006, 05:20 PM
Are you saying you got this script to work, so that you get a bookmark link that works in IE or FF?

I can't get this to work in either :-(

Best wishes

Tony

Well, I got the bookmark to work in IE, but it will not work in FF. Poo. I also cannot get the "set as homepage" to work AT ALL (after trying three or four different instructions). Totally frustrating. And let me tell you, I have posted this question in a few places and no one has offered up any help at all. I am a bit disappointed as I have been trying for months now to figure this out.

You can see my bookmark button here (if they don't delete my link)...

http://www.mens-health.com/

On my button I have the following AS...

on (release) {
getURL("javascript:window.external.AddFavorite(location.hr ef, document.title);");
}

anonymous
10-24-2006, 04:22 AM
Well I got both to work in IE and add to favorites in FireFox somewhat works... The only problem(for the time being...) is the bookmark in FF only opens in the sidebar rather than in the main window...

Will keep looking in getting it to work as well as for the script to set the homepage on FF...

This is just an .html for the moment, but you can get it working from Flash, setting the Homepage bit in another function and simply calling the appropriate function from Flash...


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>BOOKMARK & HOMEPAGE</title>

<script language="JavaScript1.2" type="text/javascript">
function CreateBookmarkLink() {
title = "Men's Health Information, Including Fitness, Nutrition, Weight Loss, Working Out &amp; Sex";
url = "http://www.mens-health.com/";
if (window.sidebar) {
// Mozilla Firefox Bookmark
alert("FIREFOX!");
window.sidebar.addPanel(title, url,"");
} else if( window.external ) {
// IE Favorite
alert("YES IE");
window.external.AddFavorite( url, title);
}
else if(window.opera && window.print) {
// Opera Hotlist
return true; }
}
</script>

</head>
<body bgcolor="#ffffff">
<a href="javascript:CreateBookmarkLink();">Add to Favorites</a>
<br><br>
<a href="#" onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage('http://www.google.com');">Set homepage </a>
</body>
</html>

soonguy
10-24-2006, 10:06 AM
Well, googling around, I find a script such as http://www.dynamicdrive.com/dynamicindex9/addbook.htm
which does work, but for FF the bookmarks appear in the sidebar. Further googling seems to suggest that this is intrinsically the only way Firefox can be made to do it. Since it is so wierd having your bookmarks open in the sidebar, I just won't go that way!! Unless anyone has found a wonderful way to get round it.

Best wishes

Tony

anonymous
10-24-2006, 11:46 AM
It seems Soon is right...

Just got that answer on the Mozilla forums...

http://forums.mozillazine.org/viewtopic.php?t=478002

But both at least work correctly in IE in the above script.

rizwan6feb
03-27-2008, 09:21 AM
window.sidebar.addPanel opens the page in the side bar rather than the main window. There is no solution to bookmark a url in Firefox using Javascript
Qualitycodes (http://www.qualitycodes.com)