Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 13th, 2005, 4:42 PM   #1
glevine
Newbie
 
Join Date: Jun 2005
Posts: 22
Rep Power: 0 glevine is on a distinguished road
dynamically creating a link element

I've been searching on the net for the last 2.5 hours about this and haven't turned up anything, so hopefully someone on this forum can help.

I want to use an external javascript file to dynamically create a link element in the <head> section of any webpage using that *.js file. This way I don't have to add the Live Bookmark link line to every page on my site individually and Firefox can pick up the support for Live Bookmarks on my site. Any suggestions about doing this? Thanks.
glevine is offline   Reply With Quote
Old Jul 14th, 2005, 10:32 AM   #2
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
I don't think that's a good idea. People who disable JavaScript won't be able to get to your RSS/Atom feeds. The code for the link tag will be much, much less than the code in the .js, and possibly the same length as the script tag in the head element that pulls in the .js page. It really is a bad thing to do if you want to maximize performance. I see no obvious reason why you'd want to do this at all.
Cerulean is offline   Reply With Quote
Old Jul 14th, 2005, 10:45 AM   #3
glevine
Newbie
 
Join Date: Jun 2005
Posts: 22
Rep Power: 0 glevine is on a distinguished road
nevermind, it turned out to be pretty simple once i decided to look for other topics similar to mine, but not really exactly what i was looking for. if anyone is interested in how to do this, here is the code that goes in your javascript file:

var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.rel = 'alternate';
link.type = 'application/rss+xml';
link.href = 'link/to/your/rss/feed';
link.title = 'title of your rss feed';
head.appendChild(link);
glevine is offline   Reply With Quote
Old Jul 14th, 2005, 10:48 AM   #4
glevine
Newbie
 
Join Date: Jun 2005
Posts: 22
Rep Power: 0 glevine is on a distinguished road
cerulean, i understand that people who disable javascript won't be able to get the rss feeds, but it makes more sense at the moment to do it this way because i would have to update thousands of pages... this way i can get the live bookmarks feature upon sooner, rather than later, and i can go back and update each page individually at a later date when i have time to do so
glevine is offline   Reply With Quote
Old Jul 14th, 2005, 11:03 AM   #5
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
write a script that will update each page... not that hard.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Jul 14th, 2005, 11:04 AM   #6
glevine
Newbie
 
Join Date: Jun 2005
Posts: 22
Rep Power: 0 glevine is on a distinguished road
don't know why i didn't think of that... good call
glevine is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:17 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC