![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2005
Posts: 22
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
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.
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jun 2005
Posts: 22
Rep Power: 0
![]() |
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); |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Jun 2005
Posts: 22
Rep Power: 0
![]() |
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
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Jun 2005
Posts: 22
Rep Power: 0
![]() |
don't know why i didn't think of that... good call
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|