问题
I do not have a specific block of code to post here, my website includes a fair bit of javascript/jquery which works great on android and modern desktop browsers (including Safari). However when I look at the site through an iphone none of the javascript is running.
Site is www.alexchapman.co.uk, I have checked that js is enabled on the iphone and I am not getting any error messages on the phone. The site is a bit slow so I am connecting to the site on the iphone via a wi-fi connection.
My question is where do I begin trying to sort this out. I don't have access to a mac. Is there anything I can run on the iphone similar to firbug or ie dev tools to try to see what's happening here? I tried the Electronic Mobile Simulator but this shows the site working fine (although I realise this isn't a proper iphone emulation)
Has anyone had a similar issue?
回答1:
You might want to turn on the Debug Console. I note the last error I find on your page is "JavaScript: Error: undefined. JavaScript execution exceeded timeout".
回答2:
I just took a look at your site in webkit, and it is complaining about your viewport meta tag. Instead of separating your viewport content parameters with semicolons, use commas. LIke this:
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
回答3:
Disable popup blocker if it's enabled under safari settings.
回答4:
There's some workarounds to test iPhone. Try one of this tips. You can rent a mac, use a virtual machine, build a hackintosh or use a developer tool that has resources to test.
However, just see the website on iPhone is not enough to solve the problem. If you need to debug, there's a way to do it via Chrome Dev Tools. Take a look at this tutorial.
Those resources can help you to discover a solution.
回答5:
This website does not seem to be designed for browsing on a mobile device. I would recommend having a separate, much simpler website specifically designed for mobile browsing. This way you can tailor your HTML/Javascipt taking into account screen size, touch sensitivity and performance. You can use the same URL and redirect to the appropriate website depending on the browser type (mobile or non-mobile). If you decide to take that route, I would recommend looking into Javascript libraries such as JQuery Mobile.
来源:https://stackoverflow.com/questions/9548228/website-javascript-not-running-on-iphone-safari