How to get the RSS URL in javascript?
September 26, 2006 12:24 PM
How do I access the RSS URL defined in the tag of a page, using javascript?
I want to use a bookmarklet to capture the RSS URL of the page I'm looking at. I'm sure there must be a document.something property that I could access, but I don't know enough javascript to figure it out.
I want to use a bookmarklet to capture the RSS URL of the page I'm looking at. I'm sure there must be a document.something property that I could access, but I don't know enough javascript to figure it out.
The bookmarklet was stripped by Mefi's XSS filtering - I figured that would happen. Visit Laughing Meme for the unfiltered bookmarklet.
posted by slhack3r at 12:37 PM on September 26, 2006
posted by slhack3r at 12:37 PM on September 26, 2006
I wrote one that turns out to be nearly the same as the previous answer, but I don't want it to be for naught:
posted by moift at 12:42 PM on September 26, 2006
javascript:var links = document.getElementsByTagName('link'); for (var i = 0; links[i] && links[i].getAttribute('type') != 'application/rss+xml'; ++i); if (links[i] && links[i].hasAttribute('href')) alert(links[i].getAttribute('href'));
posted by moift at 12:42 PM on September 26, 2006
This one will alert for all if there are multiples instead of just the first
posted by moift at 12:54 PM on September 26, 2006
javascript:var links = document.getElementsByTagName('link'); for (var i = 0; links[i]; ++i) { if (links[i].getAttribute('type') == 'application/rss+xml' && links[i].hasAttribute('href')) alert(links[i].getAttribute('href')); }
posted by moift at 12:54 PM on September 26, 2006
This thread is closed to new comments.
posted by slhack3r at 12:36 PM on September 26, 2006