I've spent the last week or so doing iPhone web development. Let me be clear - that's web development. I'm not actually writing any fancy native applications for the iPhone. While most of my time was spent on just the basic work of the app (and I'll have some server side details on that tomorrow at ArgumentCollection), I wanted to look into what - if any - tweaks were available to on the iPhone web browser. I've found two things that I think are pretty interesting.
The first and simplest tip is working with the view port. (You may need to register at Apple in order to view that link. Two points off to Apple to requiring a login for simple docs!) The view port is a simple meta tag. Here is an example:2 <meta name="apple-mobile-web-app-status-bar-style" content="black" />
2 <meta name="format-detection" content="telephone=no">
3 <meta name="apple-mobile-web-app-capable" content="yes" />
4 <meta name="apple-mobile-web-app-status-bar-style" content="black" />
5
6 <script src="/jquery/jquery.js"></script>
7 <script>
8
9 function test() {
10 $("#content").load('index3.cfm?log=<cfoutput>#randRange(1,100)#</cfoutput>');
11 }
12
13 function init() {
14 $("a").click(function(e) { $("#content").load(e.target.href);return false; });
15 }
16
17 $(document).ready(init);
18
19 </script>
20 <div id="content">
21 <cfoutput>
22 <p>
23 <a href="index3.cfm?link=#urlEncodedFormat(createUUID())#">link to me, bad</a>
24 </p>
25 <p>
26 <a href="" onClick="document.location.href='test.cfm?link=#urlEncodedFormat(createUUID())#'">link to me, js</a>
27 </p>
28
29 <p>
30 <a href="test3.cfm?dontrun=1" onClick="test();return false;">link 3</a>
31 </p>
32
33 <p>
34 <a href="index.cfm">Naked Link</a>
35 </p>
36 </cfoutput>
37 <cfdump var="#url#">
38
39 </div>
Comment 1 written by marc esher on 10 October 2008, at 4:41 AM
you should be able to get what you want with something like this:
$("#mydiv").load("blah.cfm #TheDivIWant");
Comment 2 written by Raymond Camden on 10 October 2008, at 6:16 AM
$("a").click(function(e) { $("#content").load(e.target.href+' #content');return false; });
Thank you.
Comment 3 written by marc esher on 10 October 2008, at 6:22 AM
is this for the cfbloggers iphone page?
Comment 4 written by Raymond Camden on 10 October 2008, at 6:24 AM
Comment 5 written by Raymond Camden on 10 October 2008, at 6:49 AM
Comment 6 written by Raymond Camden on 10 October 2008, at 6:51 AM
function init() {
$("a").click(function(e) { $("#content").load(e.target.href+' #content', init);return false; });
}
Comment 7 written by Pollux on 25 November 2008, at 1:19 PM
Comment 8 written by Raymond Camden on 25 November 2008, at 1:22 PM
Comment 9 written by Rex on 14 December 2008, at 4:43 AM
<meta name="apple-mobile-web-app-capable" content="yes" />
I linked the jquery plug in
I put the script function (init).
I tried all that in iphone, and the fullscreen works but when I try the link, Safari opens.
Any little help? What I have to write exactly?
Thank you very much!!
Comment 10 written by Raymond Camden on 14 December 2008, at 3:18 PM
Comment 11 written by chris on 1 February 2009, at 1:18 PM
<a href="#" onClick="javascript:window.location.href='targetURL'">Click here to change page within webapp</a>
Works just like a link but keeps you in the webapp.
PS:
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
seems unneccessary
Comment 12 written by nono on 13 February 2009, at 5:48 PM
<a href="#" onClick="javascript:window.location.href='targetURL'">Click here to change page within webapp</a>
work on first click but not on subsequent (launch Safari).
However this did the trick:
<a href="javascript:window.location.href='MyUrl.html'">Click me</a>
Comment 13 written by Sam Nicholson on 3 March 2009, at 10:19 AM
$("a").click(function(e) { $("#content").load(e.target.href+' #content', init);return false; });
} will load the content of the URL into the div with the id of content? If so, the same applies for any links which are within the returned content? Sorry if this sounds dumb but I have very little experience with AJAX and none with jQuery.
Comment 14 written by Raymond Camden on 3 March 2009, at 10:23 AM
Comment 15 written by Sam Nicholson on 3 March 2009, at 10:55 AM
$("#content a").click(function(e) { $("#content").load(e.target.href+' #content', init);return false; });
} apply it to only the A tags within the content div?
Comment 16 written by Raymond Camden on 3 March 2009, at 11:00 AM
Comment 17 written by Sam Nicholson on 3 March 2009, at 2:45 PM
Comment 18 written by Raymond Camden on 3 March 2009, at 2:59 PM
Comment 19 written by Sam Nicholson on 4 March 2009, at 4:37 AM
[Add Comment] [Subscribe to Comments]