Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to add Favorite or Homepage 1

Status
Not open for further replies.
Jan 28, 2003
149
0
0
GB
Hi,

Wonder if anyone can help me with a simple piece of JavaScript.

What command do I need to set the current page to the users homepage (preferably with a Yes/No confirmation dialog box), and likewise to add a specific address to their favorites?

Thanks in advance

B.M.
 
None, let the users decide if they want to set your page as their homepage or bookmark it. Better yet, let your content be so compelling as to entice the user into bookmarking your site. Most people have a fair idea of how to work their browsers.
 
Hi There

The following Javascript should work in Internet Explorer (version 4 or above) for adding the current page to the user's favourites.

Obviously you can alter the parameters to suit your needs.

window.external.AddFavorite(location.href, document.title).

 
dwarfthrower has a point. The user should know how to bookmark or set as homepage if he wished to do so.

The method TootingBoy showed us (all respect to him for his technical knowledge) is most often seen on porn sites or warez sites of unprofessional nature. With such a line of code on your page you will have a popup asking if you wish to add to favorites/set as homepage. You would know this is annoying if it ever happened to you.

Also if you decide to choose the method described by TootingBoy you should first check that such a method exists on the person's computer so that no JS errors occur on browsers that do not have that horrible feature! :)

Here is how to check :

if (window.external && window.external.AddFavorite)
{
window.external.AddFavorite(location.href, document.title)
}

Best luck to you. I still stand by dwarf's advice to not use such a feature at all.

Gary Haran
********************************
 
Hi

Thanks for the answers. To address the point made by Flamethrower, the user has *must* select something which will simply assist in the creation of a Favorite item. When I've seen this used before you are simply given the Add to Favorites dialog box which has a cancel button.

In my mind this is perfectly ethical as the user is in full control 100% of the time. My aim is indeed to have content that will keep the users wanting to come back, but I don't want their lack of technical understanding to keep them away.

The website in question is for a junior football club and I'm quite keen to have this feature as many of the parents are not PC literate (you wouldn't believe how many questions I've had on "how do I get to this page"!)

I'm perfectly willing to provide the website address for verification that I'm not doing this by stealth!!!

B.M.
 
BlueMonkey,

May I recommend you use it as a button or link on the page and not an automatic popup that would bug people every time they visit the page?

<script language=&quot;Javascript&quot; type=&quot;text/javacript&quot;>
if (window.external && window.external.AddFavorite)
{
document.write('<a href=&quot;javascript:window.external.AddFavorite(location.href, document.title)&quot;>Add this site to your favorites</a>&quot;)
}
</script>

Gary Haran
********************************
 
Thanks xutopia

A button or a hyperlink is exactly how I want this feature to work - if I have inadvertantly give the impression that this process will be started automatically as a pose to manually by the user I apologise to you all.

As I get to see most of my audience at least twice a week I don't want to be accused of doing stuff to their machine without their permission.

Thanks again

C

B.M.
 
Thank you very much. We've all fallen for websites adding themselves to our Favorites, or as homepage. Like I said earlier, many of my users are not very PC literate and are already successfully visiting one day, but mistyping the address the next day (it really is that bad).

If used correctly, these tools can be used effectively.

Any ideas on the homepage

PS - I'll not be able to try these examples out till after work tonight

B.M.
 
Not sure what browsers your using so here is a link to a one-fits-all script for you.


[smile]

Hope I helped / Thanks for helping
if ((Math.abs(x)<10&&Math.abs(y)<10) && (((parseInt(Math.abs(x).toString()+Math.abs(y).toString())-Math.abs(x)-Math.abs(y))%9)!=0)) {alert(&quot;I'm a monkey's uncle&quot;);}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top