View State - changing meta viewport settings?

5 views
Skip to first unread message

RyanA

unread,
Jul 11, 2007, 8:05:05 PM7/11/07
to iPhoneWebDev
Does anyone know if change you change the meta viewport settings via
javascript? If so what would the command be?

Thanks

cookiecrook

unread,
Jul 11, 2007, 8:24:50 PM7/11/07
to iPhoneWebDev
RyanA wrote:

> Does anyone know if change you change the meta viewport settings via
> javascript? If so what would the command be?

Where the meta tag has id="viewport" as in:
<meta name="viewport" id="viewport" content="width=480" />

You could use:
document.getElementById('viewport').setAttribute('content',
'width=320');

I ran into some inconsistencies with this at iPhoneDevCamp last
weekend. For example, changing the width to a smaller value would zoom
the page in as expected, changing it to a larger value would not
automatically zoom you back out. I imagine you could get better
results by explicitly setting the scale and user-scalable values each
time, but haven't had a chance to fully flesh out the intricacies.

Cheers,
James Craig

RyanA

unread,
Jul 12, 2007, 12:57:35 AM7/12/07
to iPhoneWebDev
Thanks for your input. Here is a link to a test page for the viewport
and dynamically changing its values.

BUT before you run it, note the following:

1. When the page first loads, the zoom IN and OUT buttons work fine
(by change the width and height).
2. Click the control panel button to modify the viewport settings,
then close, then click Apply changes.
3. Once you change the scale the zoom seem to break.

http://iPhoneDevcast.com/iPhone/ViewPortTest.asp

All: Feel free to grab the code and see what you guys can come up
with.

-=Ryan

Reply all
Reply to author
Forward
0 new messages