473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

changing meta tag with javascript

26
Hi
I have a scenario where I need to update meta tag content attribute at runtime using javascript .This is basically used for scenario where I m trying to integerate my application with facebook .Since facebook looks for meta tag I want to update those tags at runtime .
www.facebook.com/share_partners.php (Please go to this to see what I mean)

<meta name="title" content="Smith hails 'unique' Wable legacy" />
<meta name="description" content="John Smith claims beautiful football is the main legacy of Akhil Wable's decade at the club. " />
<link rel="image_src" href="http://www.onjd.com/design05/images/PH2/WableAFC205.jpg" />

For ex ,In above scenarios I want to update content attribute after page loads.

Also whether facebook will be able to read these updated values.(since SEO engines doesn't read )

Thanks
Aug 29 '08 #1
1 3929
Dormilich
8,658 Expert Mod 8TB
you can access the meta elements with
Expand|Select|Wrap|Line Numbers
  1. var meta = document.getElementsByTagName("meta");
then you can loop through the array and read/set the attribute values
Expand|Select|Wrap|Line Numbers
  1. var attrArray = meta[0].attributes;  // here: 1st meta element’s attributes
  2. var attrName = attrArray[0].nodeName; // get the name e.g. "name" (first attribute)
  3. attrArray[1].nodeValue = "new_attribute_value"; // set new value of "content" (2nd attribute)
Aug 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Raymond Dunton | last post by:
I am new to Javascript programming. I have a page with four small pictures. I want to click on a picture and have it open up larger in a popup window. this is what I am currently using to do...
10
by: David Komanek | last post by:
Hi all, I have a question if it is possible to manipulate the settings of character encoding in Ms Internet Explorer 5.0, 5.5 and 6.0. The problem is that the default instalation of Ms IE seems...
4
by: Kenny | last post by:
I have been trying to write a script that will increase the size of and image when you mouse over it, and decrease it to original size, when you mouse out. After a couple of attempts, this is what...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.