Link to home
Start Free TrialLog in
Avatar of Dada44
Dada44Flag for Spain

asked on

Change meta tags from a function

Hi all,

My page has already the following meta tag inside of the head section:
<meta name='description' content=''>

But at certain event (when entering a function Facebook related) I would like to change it and add these two:
 
<meta name="title" content="some about the content" />
<meta name="description" content="my web description" />
<link rel="image_src" href="http://myimage.gif" / >

How can I do that?
Thanks a lot
ASKER CERTIFIED SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dada44

ASKER

whoah! seems to work bit what about this one:
<link rel="image_src" href="http://myimage.gif" / > hoe can it be added??
Thanks!!
It is also simple and can be done in the same way but here is a different approach you might like this for other usage as well :
http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
And you are welcome. :)
Avatar of Dada44

ASKER

So if I want to achieve this:
<link rel="image_src" href="http://myimage.gif" / >

I do:
  <script type="text/javascript" src="jquery.min.js"></script>
    <script>
  $(document).ready(function () {

    addface();
});

function addface(){
var filename="http://myimage.gif";
var fileref=document.createElement("link")
  fileref.setAttribute("rel", "image_src")
  fileref.setAttribute("href", filename)
}
</script>

I don't know if it's correct, how can I check it?
Thanks a ton ;)
You can verify it by DOM as such if you are not getting an error this code works. BTW, why everything needs to be converted to JQuery? :)
Avatar of Dada44

ASKER

thanks!