|
|
Forum Member
Group: Forum Members Last Login: 2/8/2007 8:41:42 AM Posts: 45, Visits: 35
|
|
Don't ask me why , but I need to dynamically change the meta tags on my page with javascript. I can't seem to pull it off. Any ideas? |
|
|
|
Forum Member
Group: Forum Members Last Login: 2/7/2007 11:36:07 AM Posts: 38, Visits: 35
|
|
chillywilly (1/26/2007)
Don't ask me why , but I need to dynamically change the meta tags on my page with javascript. I can't seem to pull it off. Any ideas?
Yes, here is a code example on how to update document meta tag using
// First, get the array of meta-tag elements
metatags = document.getElementsByTagName("meta");
// Iterate through the array, listing them all
// Update only the Title meta tag
for (cnt = 0; cnt
{
var name = metatags[cnt].getAttribute("name");
var content = metatags[cnt].getAttribute("content");
// List the original meta tag name=content
document.write(name + " = " + content + " ");
// Update the Title meta tag
if (metatags[cnt].getAttribute("name") == "Title")
metatags[cnt].setAttribute("content", "Better document title");
}
I think this is what you were looking for. Let me know if its not what you want.
|
|
|
|
Junior Member
Group: Forum Members Last Login: 2/7/2007 3:43:42 PM Posts: 18, Visits: 23
|
|
I'm pretty sure that will do the trick as what I found was pretty similar. |
|
|
|
Forum Member
Group: Forum Members Last Login: 2/18/2007 12:58:12 PM Posts: 36, Visits: 4
|
|
I don't know much about Javascript but did the code work...still no update on whether it did or not. |
|
|
|