开发者

Is it possible to edit meta tag content via javascript before the page load event?

开发者 https://www.devze.com 2023-04-01 09:50 出处:网络
On our website we have limited access to the back-end code, so try to make as much edits to the site using JQuery, etc.,. We are currently adding meta tags to the head via JQuery using the append meth

On our website we have limited access to the back-end code, so try to make as much edits to the site using JQuery, etc.,. We are currently adding meta tags to the head via JQuery using the append method. It looks like the meta tags are being added, but Facebook is not recognizing the meta tags. We need the meta tags added for Facebook to use Open Graph. I read that ready event in JQuery allows to edit data before the page load event.

Apparently, Facebook reads the meta tags on the page load, so any changes to the Open Graph values in the meta tag must be done before the page load event.

$(document).ready(function(){
    // your c开发者_开发问答ode here
});


NO. The problem is search bots get the SOURCE of your page, not what is rendered when JS runs. They get the page just as it is served-up.


A literal answer to the question would be "yes" (since all the meta tags are in the head, and you can run JS while the rest of the document is being parsed and downloaded)), but Facebook won't execute any JavaScript so that doesn't really matter.

You need to change the actual HTML.

0

精彩评论

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