Dada44
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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. :)
http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
And you are welcome. :)
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"></scri pt>
<script>
$(document).ready(function () {
addface();
});
function addface(){
var filename="http://myimage.gif";
var fileref=document.createEle ment("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 ;)
<link rel="image_src" href="http://myimage.gif" / >
I do:
<script type="text/javascript" src="jquery.min.js"></scri
<script>
$(document).ready(function
addface();
});
function addface(){
var filename="http://myimage.gif";
var fileref=document.createEle
fileref.setAttribute("rel"
fileref.setAttribute("href
}
</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? :)
ASKER
thanks!
ASKER
<link rel="image_src" href="http://myimage.gif" / > hoe can it be added??
Thanks!!