Set As Homepage Help!!! URGENT!

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
acsodeputy
Beginner
Beginner
Posts: 5
Joined: Fri Jan 14, 2005 4:51 am
Contact:

Set As Homepage Help!!! URGENT!

Post by acsodeputy »

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);");
...}
User avatar
fredlongworthhighschool
Mega Advanced
Mega Advanced
Posts: 362
Joined: Fri Jun 27, 2003 11:34 am
Location: Manchester, England.
Contact:

Post by fredlongworthhighschool »

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.
Andy Davis
Web Designer & Smartboard Manager

Fred Longworth High School, Manchester, England.
acsodeputy
Beginner
Beginner
Posts: 5
Joined: Fri Jan 14, 2005 4:51 am
Contact:

Post by acsodeputy »

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
User avatar
fredlongworthhighschool
Mega Advanced
Mega Advanced
Posts: 362
Joined: Fri Jun 27, 2003 11:34 am
Location: Manchester, England.
Contact:

Post by fredlongworthhighschool »

I'll try and create one now and post the results shortly (assuming it works!)

Andy.
Andy Davis
Web Designer & Smartboard Manager

Fred Longworth High School, Manchester, England.
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

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
acsodeputy
Beginner
Beginner
Posts: 5
Joined: Fri Jan 14, 2005 4:51 am
Contact:

Help on setting homepage

Post by acsodeputy »

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@comcast.net
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

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: Select all

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.");
}
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: Select all

aI("text=Make this your Home page;url=javascript: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: Select all

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.");
}
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: Select all

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');");
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
acsodeputy
Beginner
Beginner
Posts: 5
Joined: Fri Jan 14, 2005 4:51 am
Contact:

Thanks!!!

Post by acsodeputy »

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
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Re: Thanks!!!

Post by kevin3442 »

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
You're welcome Dustin. Glad it works for you.

See there John? I'm the smart est... not a smart aleck! ;)

Kevin
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Re: Thanks!!!

Post by John »

kevin3442 wrote:See there John? I'm the smart est... not a smart aleck! ;)
And he wants to start already at this early hour... :roll:
John
Post Reply