Problem with javascript

M

Malcolm Walker

I found the javascript `Bookmark This Page!' shown below on a third
party Web site & I have copied & pasted it in HTML view into a web on my
system. In Preview it appears to work but does not work in my browser.
Nor, not surprisingly therefore, does it work on the Web at:

http://www.sandiwaygolf.co.uk/

I would be grateful for help in identifying why I have been unsuccessful.

Malcolm Walker

| <span style="border: 1px dashed rgb(51, 51, 51); padding: 3px;">
<script type="text/javascript">
var text = "Bookmark This Page!"
// Add your website URL between the quotations below
var site = "http://www.Bravenet.com";
// Add your site description in the quotations below
var desc = "Webtools for Webmasters"
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 += " (Ctrl+D)"
document.write(text)
}
</script> </span>|
 
M

MD Websunlimited

Hi Malcolm,

There is a line that is wrapped

document.write('<a title="Bookmark this page"
href="javascript:window.external.AddFavorite(site,desc);" ');

Make sure it is a single line.

document.write('<a title="Bookmark this page" href="javascript:window.external.AddFavorite(site,desc);" ');

Otherwise it is good code.
 
M

Malcolm Walker

Thank you for your reply. I've made the correction but the link is
still dead!
 
T

Trevor L.

Malcolm said:
I found the javascript `Bookmark This Page!' shown below on a third
party Web site & I have copied & pasted it in HTML view into a web on
my system. In Preview it appears to work but does not work in my
browser. Nor, not surprisingly therefore, does it work on the Web at:

http://www.sandiwaygolf.co.uk/

I would be grateful for help in identifying why I have been
unsuccessful.
Malcolm Walker

This is my code. I have simplified it a bit - I hope it still works.
<head>
.........
<script type="text/javascript">
var is_ie = (navigator.appVersion.indexOf('MSIE') != -1) ? true : false
function addfavs()
{
if (is_ie)
{ var appver = navigator.appVersion
var is_minor = parseFloat(appver.substring(appver.indexOf('MSIE') + 5,
appver.indexOf(';',appver.indexOf('MSIE'))
))
var is_major = parseInt(is_minor) }

if (is_ie && is_major >= '4')
var text = '<span style= "cursor:pointer;" '
+ ' onclick="window.external.AddFavorite'
+ '(\'http://tandcl.homemail.com.au\',top.document.title)">'
// alter above line to your website
+ 'Bookmark This Page!'
+ '</span>'
else
var text = 'To Bookmark This Page - Press (Ctrl+D)'

document.getElementById("addfav").innerHTML = text
}
</script>
</head>
<body onload '"addfavs">
............
<span id="addfav"></span>
............
</body>
 
J

Jon Spivey

Hi Malcolm,
The code works in Firefox in as much as the link won't be written out - IE
is the only browser that allows adding to favourites via script. Apart from
the issue Mike pointed out I can't see anything wrong with the code. Can we
see the offending page? Alternative you might want to try simplifying the
code
<script type="text/javascript">
if(document.all)document.write('<a href="javascript:;"
onclick="window.external.AddFavorite(location.href,document.title);return
false;">Bookmark this page</a>')
</script>
Ensuring this is all on one line.
 
M

Malcolm Walker

I have come to realise that the script works in IE but as it is
compatible displays text in other browsers.

My thanks & apologies to those who have responded to my messages in this
thread. It is hard for an old dog to learn new tricks!
 
M

Malcolm Walker

Jon - thank you. Your message & my previous message are timed on my
computer at one minute apart. I had come to realise what you have
explained at much the same time!

Thank you for the `simple' code that I will try later. The site is at:
www.sandiwaygolf.co.uk/ if you still wish to see it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top