Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inject a meta tag from a document's body?

I need to add a meta tag (specfically, <meta name="apple-itunes-app" content="app-id=xxxxx">) to a certain page, but the way our templates are set up, it's not possible for me to edit the code for the HEAD tag directly (for corporate, not technical, reasons).

Therefore, is there a way using JQuery within the BODY tag to add this meta tag?

like image 354
Steve Avatar asked Nov 29 '22 16:11

Steve


1 Answers

Maybe you can try this:

jQuery:

$('head').append('<meta name="apple-itunes-app" content="app-id=xxxxx">');

Javascript:

document.getElementsByTagName('head')[0].appendChild('<meta name="apple-itunes-app" content="app-id=xxxxx">');
like image 66
Oscar Jara Avatar answered Dec 15 '22 05:12

Oscar Jara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!