HI chaps, I was wondering if it is possible to add a meta tag using jquery to an html page before the page loads.
The reason why I ask, is because I have a page with no viewport meta tag on and it should have it only when the resolution drops below 700px - <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1"/>
Any idea?
thanks
Violet_82
89
Posting Whiz in Training
Recommended Answers
Jump to PostWell I guess that would be possible :). Maybe something like:
$(window).resize(function() { // Do your width checks etc. here, check out the jQuery website for more info. if(page_width < 700) { // Create <meta> tag. $('head').append('<meta name="bla" content="test">'); } else { // Remove the <meta> tag. …
Jump to PostYes it does, when it resizes the <meta> tags are added, but I'm not sure how dynamically added <meta> tags work for search engine spiders etc.
Jump to PostAlso, check out CSS3 media queries (Google it). They're probably perfect for your situation!
All 12 Replies
minitauros
151
Junior Poster
Featured Poster
Violet_82
89
Posting Whiz in Training
minitauros
151
Junior Poster
Featured Poster
minitauros
151
Junior Poster
Featured Poster
Violet_82
89
Posting Whiz in Training
minitauros
151
Junior Poster
Featured Poster
Violet_82
89
Posting Whiz in Training
minitauros
151
Junior Poster
Featured Poster
Violet_82
89
Posting Whiz in Training
minitauros
151
Junior Poster
Featured Poster
Violet_82
89
Posting Whiz in Training
Ajith_1
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.