We’d like to remind Forumites to please avoid political debate on the Forum.
This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
The Forum now has a brand new text editor, adding a bunch of handy features to use when creating posts. Read more in our how-to guide
Please help - Javascript cracking me up!
Vic_980
Posts: 115 Forumite
in Techie Stuff
I'm trying to add a simple link into a HTML page that will add a page to someone's favourites in IE, using a Javascript function.
So, click the link, page is added to favorites - similar to the way it's done on the MSE home page.
Code I have in the page is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<Script Language = "Javascript" Type="Text/Javascript">
function addToFavorites()
!!
window.external.AddFavorite(location.href, document.title);
}
</script>
<p><a href="javascript:addToFavorites()">Click here to add to favourites</a></p>
</body>
</html>
Every time I click the link I get an 'Error on Page' message in the bottom left of IE.
Anyone spot what the problem is? I'm cracking up, it's obviously something silly.
Problem appears to be with location.href - if I substitute something else in here e.g. "http://www.ebay.com", the page works fine.
Any ideas?? P.S. The left squiggly bracket appears as !! on this chat forum for some reason. But it is a left squiqqly bracket in my code!
So, click the link, page is added to favorites - similar to the way it's done on the MSE home page.
Code I have in the page is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<Script Language = "Javascript" Type="Text/Javascript">
function addToFavorites()
!!
window.external.AddFavorite(location.href, document.title);
}
</script>
<p><a href="javascript:addToFavorites()">Click here to add to favourites</a></p>
</body>
</html>
Every time I click the link I get an 'Error on Page' message in the bottom left of IE.
Anyone spot what the problem is? I'm cracking up, it's obviously something silly.
Problem appears to be with location.href - if I substitute something else in here e.g. "http://www.ebay.com", the page works fine.
Any ideas?? P.S. The left squiggly bracket appears as !! on this chat forum for some reason. But it is a left squiqqly bracket in my code!
0
Comments
-
Sorted - permissions problem. Bl**dy Windows...0
This discussion has been closed.
Confirm your email address to Create Threads and Reply
Categories
- All Categories
- 353.5K Banking & Borrowing
- 254.1K Reduce Debt & Boost Income
- 455K Spending & Discounts
- 246.6K Work, Benefits & Business
- 602.9K Mortgages, Homes & Bills
- 178.1K Life & Family
- 260.6K Travel & Transport
- 1.5M Hobbies & Leisure
- 16K Discuss & Feedback
- 37.7K Read-Only Boards