PDA

View Full Version : You guessed it ... JavaScript again


Pauly
November 14th, 2004, 13:36
<script type="text/javascript">
var text = "Bookmark this Page"
// Add your website URL between the quotations below
var site = "http://www.takinghold.co.uk";
// Add your site description in the quotations below
var desc = "TakingHold.co.uk // Not for the sensitive"

var ver = navigator.appName
var num = parseInt(navigator.appVersion)
if ((ver == "Microsoft Internet Explorer")&&(num >= 4))
{
document.write('<a title="Bookmark this Page" href="javascript:window.external.AddFavorite(site,desc);" ');
document.write('onMouseOver=" window.status=')
document.write("text; return true ")
document.write('"onMouseOut=" window.status=')
document.write("' '; return true ")
document.write('">'+ text + '</a>')
}
else
{
text += " Press <strong>Ctrl + D</strong>"
document.write("To " + text)
}
</script>

Right now (I believe), this action adds the domain listed at the top to favourites, however because I am including this to cut down on code I would like it to work on the page it's included.

Can anyone explain how I would do this please?

the_pm
November 14th, 2004, 18:01
A quick search produced this little bit of code:

<FORM>
<INPUT TYPE="button" VALUE="Add to Favorites" onClick='window.external.AddFavorite(location.href , document.title);'>
</FORM>

I'm sure you can style it as input type="image" and it will have the same effect. How badly do you want the "add to favorites" function to be a hotkey? You could just move this little script into a function and call the function from a keypress. I've never done this personally, but I can't imagine it's hard to do...

Pauly
November 14th, 2004, 18:05
Doesn't work in Mozilla run browsers, that's why I decided to use the above code instead.

the_pm
November 14th, 2004, 21:29
Hmm, just reading through the above code seems to indicate that on all non-IE declared browsers, the output simply returns instructions for the visitor to press Ctrl-D.

Pauly
November 14th, 2004, 21:48
Oh I see what you're getting at now ;) Stupid me :lol:

the_pm
November 14th, 2004, 22:07
I say not to bother with scripts like this. People know how to bookmark sites. If someone doesn't, then he/she certainly won't know how to use the bookmark anyway. Putting instructions on a page for bookmarking is sort of like putting instructions on the page for how to use the back, next and refresh buttons. It just doesn't seem necessary to me. Plus, there's nothing more annoying than pressing the wrong link by accident and discovering I just bookmarked a site by accident.

Pauly
November 15th, 2004, 00:09
I agree to an extent but 'Client gets what client wants' ;)

the_pm
November 15th, 2004, 00:11
Yes, so long as the client fully understand what he or she is getting. ;)

Eh, make it as easy on yourself as possible. There are many different ways to script this - pick a few, test 'em and use one.

Pauly
November 15th, 2004, 00:58
I'm using the standard one, like you put and then just using an else statement, literally 10 lines that's it :)