Firefox and Javascript issue
January 4, 2007 12:02 PM
Subscribe
I'm looking for JavaScript code that successfully updates the href value for the "application/rss+xml" link in a way that enables the Firefox Live Bookmarks functionality to work with a href value assigned at run-time.
So here is example code that works in IE7, but not Firefox 1.5/2.0. The value is changed in the DOM of FF, but clicking the Live Bookmarks icon brings one to non_existant.xml.
<html><head><link rel="alternate" type="application/rss+xml" id="test" title="Test" href="non_existant.xml"></head>
<body>
<script type="text/javascript">
document.getElementById('test').setAttribute('href','test.xml');
//or alternatively
document.getElementById('test').href= "test.xml";
</script></body></html>
posted by McGuillicuddy to technology (6 comments total)
3 users marked this as a favorite
var link = document.createElement("link"); link.setAttribute("rel", "alternate"); link.setAttribute("type", "application/rss+xml"); link.setAttribute("title", "some title"); link.setAttribute("href", "exists.html"); document.childNodes[0].appendChild(link);(document.childNodes[0] is the head element)Using DOM manipulation to replace or remove the existing links has no effect on Firefox's display of the Live Bookmarks. That, as well as
what appears to be the code Firefox uses to handle Live Bookmarks leads me to believe Firefox ignores link removal completely. This means you can add additional feeds to a page, but you cannot remove existing feeds. If you only need to generate one dynamic feed per page, you can omit your hard coded link tag and use the above code to dynamically generate a link element and add it to the page.
posted by null terminated at 1:56 PM on January 4, 2007