I'm trying to insert a new meta tag within the Head, I'm using a content managment system that won't allow editing within the Head so I'm attempting to do this using jQuery. Unfortunately I can't it to work.
This is the code I've added to the following webpage: http://www.newcastlegateshead.com
<script type="text/javascript">
$("head").append("<meta name=viewport content=width=400, initial-scale=0.45, minimum- scale=0.45/><link rel=apple-touch-icon href=/images/customIcon.png/><meta name=apple-mobile-web-app-capable content=no /><meta name=apple-mobile-web-app-status-bar-style content=black-translucent /><link rel=apple-touch-icon-precomposed href=/images/customIcon.png/> ");
</script>
Definition and Usage. The <meta> tag defines metadata about an HTML document. Metadata is data (information) about data. <meta> tags always go inside the <head> element, and are typically used to specify character set, page description, keywords, author of the document, and viewport settings.
Defining MetadataThis element is always placed within the <head> section of the page. It cannot overlap the </head> closing tag. Note that <meta> is an empty element, and does not need a closing tag.
Try your code within
<script type="text/javascript">
$(document).ready(function() {
$("head").append("<meta name=viewport content=width=400, initial-scale=0.45, minimum- scale=0.45/><link rel=apple-touch-icon href=/images/customIcon.png/><meta name=apple-mobile-web-app-capable content=no /><meta name=apple-mobile-web-app-status-bar-style content=black-translucent /><link rel=apple-touch-icon-precomposed href=/images/customIcon.png/> ");
});
</script>
Short form of $(document).ready(function() {...})
is:
jQuery(function ($) {
// Your code
})
This will ensure that you code will execute during onload
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With