简体   繁体   中英

Move code generated in <body> to <head>

Have built a function on a video platform so it generate Facebook OG:Meta video data when generating embed code for each Video. The last problem is to get the Meta data up to the head from body

What i want is to wrap the generated meta data in "some code" and then rewrite it in where i can place a code / string

There must exist a php or javascript function for this ?

In the following example I moved the DIVs from the body to the head, with JavaScript. I used DIVs to demonstrate the working. You can

link: script demonstration@jsfiddle

You should replace the DIV with META:

metaTAGs = document.getElementsByTagName( "DIV" );

Becomes:

metaTAGs = document.getElementsByTagName( "META" );

link: Your script, fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM