Programming Help Forums
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Javascript to change meta tags? Expand / Collapse
Author
Message
Posted 1/26/2007 12:30:02 PM
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?
Post #81
Posted 1/26/2007 1:50:09 PM
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.
Post #86
Posted 2/6/2007 4:24:25 PM
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.
Post #245
Posted 2/17/2007 9:43:17 PM
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.
Post #334
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: ProgrammingHelp, Viral Unity, Matt.Hill, DaveL, Alex.D

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 10:49am

Powered By InstantForum.NET v4.1.4 © 2011
Execution: 0.671. 18 queries. Compression Disabled.