Вопрос

i have this cod in Html:

<html>
<head>
    <title>test page</title>
    <meta name="keywords" content="???">
</head>
<body>
    <p><a href="#">sampel1</a></p>
    <p><a href="#">sampel2</a></p>
    <p><a href="#">sampel3</a></p>
</body>
</html>

can i replace javascript code with ???? in header keyword to take link name for meta keyword? and print like this:

<html>
<head>
    <title>test page</title>
    <meta name="keywords" content="sampel1,sampel2,sampel3">
</head>
<body>
    <p><a href="#">sampel1</a></p>
    <p><a href="#">sampel2</a></p>
    <p><a href="#/">sampel3</a></p>
</body>
</html>
Это было полезно?

Решение

You may set and change metadata after the DOM finishes loading, but unless you intend to read in the values using JavaScript, there is likely to be little benefit in doing so as the browser has already used any applicable metadata when the document initially loads, and Google is likely to pay no notice to any metadata set by Javascript.

Strongly consider using a server side solution, such as PHP.

Другие советы

$("meta[name='keywords']").attr("content", "sampel1,sampel2,sampel3");

Demo

As it was said before, there is pretty much no point of doing this. A server-side solution would have to be used.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top