问题描述:

Hey guys I'm new to this and I'm having a problem with some a meta tag.

I'm trying to create a mobile website for an iPhone interface.

The problem though is that a viewport meta tag will not function on my site.

I decided to use a javascript code that works but is only gesture activated meaning the script will not function until the user zooms in a bit on the screen.

Code's below, see if you can help.

thanks.

 <script type="text/javascript">

(function(doc) {

var addEvent = 'addEventListener',

type = 'gesturestart',

qsa = 'querySelectorAll',

scales = [1, 1],

meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];

function fix() {

meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];

doc.removeEventListener(type, fix, true);

}

if ((meta = meta[meta.length - 1]) && addEvent in doc) {

fix();

scales = [.25, 1.6];

doc[addEvent](type, fix, true);

}

}(document));

</script>

相关阅读:
Top