Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:57
Set As Homepage Help!!! URGENT!
Poster: acsodeputy
Dated: Friday January 14 2005 - 14:20:57 GMT
Does anyone know how to set a link to set as homepage? This is what I have found, but need help setting up. I have my menu written in javascript, go to http://www.fbc-lc.org and view source to see what I'm saying...
This is waht I fould: (But where do i put this?)
function doSomething( vThis )
{
vThis.style.behavior="url(#default#homepage)";
vThis.setHomePage("http://www.fbc-lc.org");
}
And for my menu link:
///new menu item(){ blah blah...
...
...
aI("text=Set as Homepage;url=javascript:doSomething(this);");
...}
Poster: fredlongworthhighschool
Dated: Friday January 14 2005 - 15:45:40 GMT
Have you read my reply to your first question about a link to create a bookmark? I would imagine it's the same process.
Andy.
Poster: acsodeputy
Dated: Friday January 14 2005 - 15:48:07 GMT
Yes, i did see your reply. It didn't work. I got the bookmark script to work. I saw this reply else where but did'nt know where to place the function.
Thanks again for all help!
-Dustin
Poster: fredlongworthhighschool
Dated: Friday January 14 2005 - 15:56:45 GMT
I'll try and create one now and post the results shortly (assuming it works!)
Andy.
Poster: kevin3442
Dated: Monday January 17 2005 - 20:48:22 GMT
Hi Dustin,
acsodeputy wrote:
Yes, i did see your reply. It didn't work....
The function that Andy Posted in your other, related thread, for adding the page to Favorites (bookmarking), actually does work (BTW, thanks for jumping in and helping Andy!). But in his eagerness to help, it looks like Andy left out the closing curly brace } at the bottom of the function definition. If you tried to run the page with the function like that, you probably would have gotten a "Done but with errors on page" message, and the main menu probably would not have shown up at all. Easy to fix... Just add a } at the bottom of the function definition, and it should work fine.
Once you add the curly brace, you may still get a permission denied error when testing the function locally (i.e., loading a test page directly from your hard drive then clicking the menu item will generate the "permission denied" error and the function won't work ). But if you upload the page to a webserver, and load the page through http, then it should work just fine, opening the "Add Favorite" dialog. Note that the function uses document.title, so your pages should have the title attribute set in order for the added favorite to have a description. If you don't have a title in your pages, holler and I can post an alternative method.
Defining a menu item that lets you "set this page as your home page" is a little more involved. The method you came across (code you posted) looks like it's meant to be called from an onclick handler in a static link; it probably will not work in a menu item. But I think it could still be done, with a slightly different approach. If you're still interested in trying that, let us know and we'll whip something up.
Cheers,
Kevin
Help on setting homepage
Poster: acsodeputy
Dated: Monday January 24 2005 - 2:36:00 GMT
Kevin,
I did see the reply. I would like help with the Set as Homepage command. I've tried about everything. And, thanks for correcting the code, i'm going to change it right now!
Thanks again,
acsodeputy __at__ comcast.net
Poster: kevin3442
Dated: Monday January 24 2005 - 21:01:24 GMT
Hi Dustin,
FOR A "SET AS HOME PAGE" FUNCTION
Place the following code at the top of your menu_data.js file (or, if you're familiar with js, load it into the page however suits you).
Code:
function mm_setAsHomePage()
{
if (ie5 || ie55) {
itemObj = gmobj("el" + _itemRef);
itemObj.style.behavior = "url(#default#homepage)";
itemObj.setHomepage(location.href);
}
else
alert("Sorry, your browser does not support this function.");
}
{
if (ie5 || ie55) {
itemObj = gmobj("el" + _itemRef);
itemObj.style.behavior = "url(#default#homepage)";
itemObj.setHomepage(location.href);
}
else
alert("Sorry, your browser does not support this function.");
}
You can now call this function from any menu item to set the current page as your home page. Appropriate aI() construction for the menu item would look like one of the following:
Code:
aI("text=Make this your Home page;url=javascript:mm_setAsHomePage();");
aI("text=Make us your Home;clickfunction=mm_setAsHomePage();");
aI("text=Make us your Home;clickfunction=mm_setAsHomePage();");
You can use either the url property or the clickfunciton property to call setAsHomePage(); both should work. I believe this approach to homepage setting only works in IE5+. I only have IE6 instralled right now, and it works on that. Might be worth testing in itehr versions before uploading to your site (note... you should test through a web server if you can... might not work right if testing locally).
FOR A VERSATILE BOOKMARKING FUNCTION
The following function is a somewhat versatile bookmarking (favorites) function.
Code:
function mm_addToFavorites()
{
if (window.external)
{
if (arguments.length < 1)
window.external.AddFavorite(location.href, document.title);
if (arguments.length == 1)
window.external.AddFavorite(location.href, arguments[0]);
if (arguments.length == 2)
window.external.AddFavorite(arguments[0], arguments[1]);
}
else
alert("Sorry, your browser doesn't support automated bookmarks.\nYou'll have to do it manually.");
}
{
if (window.external)
{
if (arguments.length < 1)
window.external.AddFavorite(location.href, document.title);
if (arguments.length == 1)
window.external.AddFavorite(location.href, arguments[0]);
if (arguments.length == 2)
window.external.AddFavorite(arguments[0], arguments[1]);
}
else
alert("Sorry, your browser doesn't support automated bookmarks.\nYou'll have to do it manually.");
}
The funciton can be called with no parameters, one parameter, or two parameters passed.
mm_addToFavorites() - no parameters - opens the Add Favorite dialog, using the current page's URL as the favorite location and the current page's title as the favorite name.
mm_addToFavorites(string favName) - one parameter - opens the Add favorite dialog, using the current page's URL as the favorite location and the value of favName as the favorite name.
mm_addToFavorites(string favURL, string favName) - two parameters - opens the Add favorite dialog, using the value of favURL as the favorite location and the value of favName as the favorite name.
Examples:
Code:
aI("text=Add us to your Favorites;url=javascript:mm_addToFavorites();");
aI("text=Make us a Favorite;url=javascript:mm_addToFavorites('The Best Site Ever');");
aI("text=Bookmark Us;url=javascript:mm_addToFavorites('http://www.bestsiteever.com', 'The Best Site Ever');");
aI("text=Make us a Favorite;url=javascript:mm_addToFavorites('The Best Site Ever');");
aI("text=Bookmark Us;url=javascript:mm_addToFavorites('http://www.bestsiteever.com', 'The Best Site Ever');");
Should work in IE5+. Make sure to test it using a real web server... it'll probably generate a permission denied error if you try to test locally.
Cheers,
Kevin
Thanks!!!
Poster: acsodeputy
Dated: Monday January 24 2005 - 22:29:22 GMT
Kevin,
Thanks a TON! You are the smartest... It worked perfectly without any problems at all!
Thanks again.
If you need anything, email me!
Dustin Jones
Re: Thanks!!!
Poster: kevin3442
Dated: Tuesday January 25 2005 - 0:44:28 GMT
acsodeputy wrote:
Kevin,
Thanks a TON! You are the smartest... It worked perfectly without any problems at all!
Thanks again.
If you need anything, email me!
Dustin Jones
Thanks a TON! You are the smartest... It worked perfectly without any problems at all!
Thanks again.
If you need anything, email me!
Dustin Jones
You're welcome Dustin. Glad it works for you.
See there John? I'm the smart est... not a smart aleck!
Kevin
Re: Thanks!!!
Poster: John
Dated: Tuesday January 25 2005 - 14:39:19 GMT
kevin3442 wrote:
See there John? I'm the smart est... not a smart aleck!
And he wants to start already at this early hour...