简体   繁体   中英

Set Meta Tag With jQuery

I'm having trouble with a mobile page that uses a site of ours in an iframe.

It works fine on desktop but on mobile the page doesn't resize correctly. Based on internal testing it seems that the page is missing this meta tag: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

Is there any way to set that via jQuery and have it actually take effect?

In theory I believe that using this SO article I could inject the meta tag like this:

$('head').append('<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">');

But it seems the problem really comes down to forcing it to re-parse the html. Is there a way I could do that?

Yes you can append a meta tag, but no you can't force reparsing of the html. The browser is going to ignore any changes you make.

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