开发者

Metatag replacement in client side

I have requirement where i need replace the Meta Tags on client side based on some user selection. For that what i have tried is i have meta content with in the DIV Tag. On Java script i am planning to replace. Div and innerhtml My Meta taga are placed with the Head tag. Using the DIV tag i am not able to put the meta tags dynimically. I am able to place all other type of content except Meta tag.

I would like t开发者_开发问答o know is there any limitation what we can place and what we can not place in DIV tag.


You can use jQuery to select and replace metatags in the header:

$('meta').attr('charset');

This would return the charset such as "UTF-8".

To replace it with something else, you can use.

$('meta').attr('charset','somethingelse');

Likewise

$('meta').attr('author','ctrl-alt-dileep');

If you don't want to user jQuery try https://developer.mozilla.org/en/DOM/element.getElementsByTagName

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜