homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Dynamic meta tag depending on URL?

 12:07 pm on Jul 18, 2012 (gmt 0)

Is it possible to have dynamic meta tag depending on URL?


If i have www.example.com

<meta name="example" content="example">.

If it is home.example.com

<meta name="example" content="home example">

both URL redirects to same html page.

Please help



 1:38 pm on Jul 18, 2012 (gmt 0)

Perfectly possible. On a small site store the data in an array. On a big site use a database.

However, I have to ask 'where does redirecting come into things?' You're either serving a page or sending a redirect.


 12:25 am on Jul 20, 2012 (gmt 0)

I suspect he either means a rewrite or solves to the same page.

As g1smd says it is possibly, but will require some sort of server side scripting language. What scripting language is available on the web server.


 6:44 am on Jul 20, 2012 (gmt 0)

Ouch. If you're rewriting more than one URL to show the same content, you've got bigger problems than how to word the <meta> tag.

But yes, I think it can be done in about four lines of javascript, since that's where we are.


 6:49 am on Jul 20, 2012 (gmt 0)

I have done using the below javascript

window.getSelection ? yourTag.name= ‘tagname' : yourTag.Name= ‘tagname '


 1:18 pm on Jul 20, 2012 (gmt 0)

That sounds like a very bad idea.


 9:52 pm on Jul 20, 2012 (gmt 0)

Do you mean the javascript itself or the rewrite?


 1:18 pm on Jul 23, 2012 (gmt 0)

JavaScript is not the place to be doing this. What's the point of rewriting meta data about the document after you've already started serving the document? For one thing, those without JavaScript will end up getting different meta data (think about search engines). But even more importantly, if you've got home.example.com serving the same content (or nearly the same, if you take meta data into account), as example.com, then (as lucy24 pointed out) you're going to dilute the value of your content in the eyes of search engines.


 12:53 am on Jul 24, 2012 (gmt 0)

Which is why my original question to him was "What scripting language is available on the web server."
Client site scripting is not a good solution as Fotiman's pointing out.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved