JavaScript - Posting Iphone Gps Coordinates To Sql
Hi Guys.
Trying to pass variables from the javascript into my php script and into my SQL query so i can track the location of the iphone. So far i have... Code: <script type="text/javascript"> function getGPS() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showGPS, gpsError); } else { gpsText.innerText = "No GPS Functionality."; } } long = position.coords.longitude; lat = position.coords.latitude; function gpsError(error) { alert("GPS Error: "+error.code+", "+error.message); } function showGPS(position) { gpsText.innerHTML = "<?php $long = "".$_GET['long'].""; $lat = "".$_GET['lat'].""; $sqldel = "INSERT INTO `location` (`id` ,`user_id` ,`long` ,`lat`) VALUES (NULL , '$user', '$long','$lat' );"; mysql_query($sqldel) or die(mysql_error()); echo "$long"; echo "$lat"; ?>"; } </script> This gets the coordinates in javascript and the php runs and i get a new record in the database but it doesnt pass the variables from java to php. Anyone know a workaround to get the variables from the iphone to sql on a single page? I want this to run in the background and refresh every now and then so i can track users location. thanks. Adam. Similar TutorialsCan anyone help me set coordinates for an image I want to add to my page? I have the center coords where I want it to be places x is 400 and y is 90. I've searched all over the internet trying to find a solution.
Hey guys/gals, do ya know an efficient way to get the coordinates of a pictures so that I can use them to create a map? It is a rectangle. Here is the code I set up for a page: Code: <HTML> <HEAD> <TITLE>Cyrus</TITLE> </HEAD> <BODY BGCOLOR=black> <div align="center"> <table border="0"; cellspacing="0"; cellpadding="0"> <tr> <td><img src="http://i732.photobucket.com/albums/ww329/Chrishick/pageheadername.png"; width=900px; hieght=160px;></td> </tr> <tr> <td><img src="http://i732.photobucket.com/albums/ww329/Chrishick/navbar.png" width=900px; border="none" usemap="#navbar"></td> </tr> <tr> <td> <br> <br> <table border="0"; width=900px> <tr> <td> <div align="left"><img src="http://i732.photobucket.com/albums/ww329/Chrishick/appearance-2.png"; width=466px; hieght=320px></div> </td> <td> <div align="right"><img src="http://i732.photobucket.com/albums/ww329/Chrishick/equipment.png"> <br><br> <img src="http://i732.photobucket.com/albums/ww329/Chrishick/personality.png"> </div> </td> </tr> </table> </td> </tr> <tr> <td></td> </tr> <tr> <td> <div align="center"><img src="http://i732.photobucket.com/albums/ww329/Chrishick/brought.png"></div></td> </tr> </table> </div> <map name="navbar"> <area shape="rect" coords="247,185,445,220" href="http://www.roleplayandwritinghaven.com/forum.htm" alt="Forum" /> </map> </BODY> </HTML> Hi, I would like to get the Lat/Lng coordinates into teh values in my form but instead I get N/E values, Can anyone please help? Here is my page: http://www.nakedsloth.com/where/default.php here is my code: Code: <?php include_once("common.php"); $markers = mysql_query("SELECT * FROM wheremarkers1"); while($row1 = mysql_fetch_array($markers)) { // echo 'Lat: '.$row1['rslat']; // echo 'Long: '.$row1['rslon']; // echo 'Email: '.$row1['rsemail']; // echo 'Name: '.$row1['rsname']; // echo 'Desc: '.$row1['rsdesc']; } // $lat = $_REQUEST['lat']; // $lng = $_REQUEST['lng']; // if($lat != 51.464960 && $lng != -1.40625){ // $lat = $_POST['lat']; // $lng = $_POST['lng']; // } ?> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <!-- Bootstrap core CSS --> <link href="css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="css/navbar-fixed-top.css" rel="stylesheet"> <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]--> <script src="js/ie-emulation-modes-warning.js"></script> </head> <style> body{ font-family: arial; font-size: 13px; width:100%; } #container{ width:100%; } #mapCanvas { width: 70%; height: 80%; float: left; } #infoPanel { width: 400px; float: left; margin-left: 10px; } #infoPanel div { margin-bottom: 5px; } #markerStatus { display:none; } #info { display:none; } #geot { display:none; } body { font: normal 10pt Helvetica, Arial; } ul#topmenu { height:30px; width:100%; margin-top:0px;} ul#topmenu li { display:block; float:left; margin-right:10px; margin-top:14px; } .telephone { display:none; } .website { display:none; } </style> <body style="margin:0px; border:0px; padding:0px;"> <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text/javascript"> var geocoder = new google.maps.Geocoder(); $( document ).ready(function() { }); $( document ).ready(function() { $("#rscategory").change(function(){ var id = $(this).find("option:selected").attr("id"); switch (id){ case "poi": $(".telephone").css( "display","block" ); $(".website").css( "display","block" ); $('input[name="rswebsite"]').val('n/a'); $('input[name="rstelephone"]').val('0'); break; case "hiddenmsg": $(".telephone").css( "display","none" ); $(".website").css( "display","none" ); $('input[name="rswebsite"]').val('n/a'); $('input[name="rstelephone"]').val('0'); break; case "landmark": $(".telephone").css( "display","none" ); $(".website").css( "display","none" ); $('input[name="rswebsite"]').val('n/a'); $('input[name="rstelephone"]').val('0'); break; case "pub": $(".telephone").css( "display","none" ); $(".website").css( "display","none" ); break; case "cafe": $(".telephone").css( "display","none" ); $(".website").css( "display","none" ); break; case "GreatView": $(".telephone").css( "display","none" ); $(".website").css( "display","none" ); $('input[name="rswebsite"]').val('n/a'); $('input[name="rstelephone"]').val('0'); break; } }); }); function geocodePosition(pos) { geocoder.geocode({ latLng: pos }, function(responses) { if (responses && responses.length > 0) { updateMarkerAddress(responses[0].formatted_address); updateMarkerCity(responses[6].formatted_address); updateMarkerCountry(responses[7].formatted_address); } else { updateMarkerAddress('Cannot determine address at this location.'); } var country; for (i=0;i<results[0].address_components.length;i++){ for (j=0;j<results[0].address_components[i].types.length;j++){ if(results[0].address_components[i].types[j]=="Region") country = results[0].address_components[i].long_name } } var city; city = results[1].address_component['rsCity'] }); } function updateMarkerStatus(str) { document.getElementById('markerStatus').innerHTML = str; } function updateMarkerPosition(latLng) { document.getElementById('info').innerHTML = [ latLng.lat(), latLng.lng() ].join(', '); latDir = "N"; lngDir = "E"; if(latLng.lat() < 0){ latDir = "S"; } if(latLng.lng() < 0){ lngDir = "W"; } qlat = Math.abs(latLng.lat()); ilat = Math.floor(qlat); xlat = ((qlat - ilat)*60); qlng = Math.abs(latLng.lng()); ilng = Math.floor(qlng); xlng = ((qlng - ilng)*60); xlat = Math.round(xlat*1000)/1000; xlng = Math.round(xlng*1000)/1000; d2 = xlat.toFixed(3); e2 = xlng.toFixed(3); d1 = ilat.toString(); d2 = d2.toString(); e1 = ilng.toString(); e2 = e2.toString(); n = Math.abs(latLng.lat()); // Change to positive var decimal = n - Math.floor(n) var decimal = n - Math.floor(n); document.getElementById('geot').innerHTML = [ latDir + ' ' + d1 + ' ' + d2, lngDir + ' ' + e1 + ' ' + e2 ].join(', '); document.form1.rsLat.value = [ latLng.lat()]; document.form1.rsLong.value = [ latLng.lng()]; document.form1.rsLat.value = [ latDir + ' ' + d1 + ' ' + d2]; document.form1.rsLong.value = [ lngDir + ' ' + e1 + ' ' + e2]; } function updateMarkerAddress(str) { document.getElementById('address').innerHTML = str; } function updateMarkerCity(city) { document.getElementById('city').innerHTML = city; } function updateMarkerCountry(country) { document.getElementById('country').innerHTML = country; } function centerPosition(newgeo,newzoom) { // document.getElementById('mcenter').innerHTML = [newgeo]; // document.getElementById('mzoom').innerHTML = [newzoom]; // document.form2.mcenter2.value = [newgeo]; // document.form2.mzoom2.value = [newzoom]; document.form1.mcenter1.value = [newgeo]; document.form1.mzoom1.value = [newzoom]; } function initialize() { var latLng = new google.maps.LatLng(51.507222, -0.1275); var map = new google.maps.Map(document.getElementById('mapCanvas'), { zoom: 4, center: latLng, mapTypeId: google.maps.MapTypeId.ROADMAP }); var marker = new google.maps.Marker({ position: latLng, title: 'Point A', map: map, draggable: true }); // Update current position info. updateMarkerPosition(latLng); geocodePosition(latLng); // Add dragging event listeners. google.maps.event.addListener(marker, 'dragstart', function() { updateMarkerAddress('Dragging...'); updateMarkerCity(''); updateMarkerCountry(''); }); google.maps.event.addListener(marker, 'drag', function() { updateMarkerStatus('Dragging...'); updateMarkerPosition(marker.getPosition()); }); google.maps.event.addListener(marker, 'dragend', function() { updateMarkerStatus('Drag ended'); geocodePosition(marker.getPosition()); }); google.maps.event.addListener(map, 'bounds_changed', function(){ var newgeo = map.get('center'); var newzoom = map.get('zoom'); centerPosition(newgeo,newzoom); }); } // Onload handler to fire off the app. google.maps.event.addDomListener(window, 'load', initialize); </script> <!-- Fixed navbar --> <div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Project name</a> </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#about">About</a></li> <li><a href="#contact">Contact</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <li><a href="#">Action</a></li> <li><a href="#">Another action</a></li> <li><a href="#">Something else here</a></li> <li class="divider"></li> <li class="dropdown-header">Nav header</li> <li><a href="#">Separated link</a></li> <li><a href="#">One more separated link</a></li> </ul> </li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="../navbar/">Default</a></li> <li><a href="../navbar-static-top/">Static top</a></li> <li class="active"><a href="./">Fixed top</a></li> </ul> </div><!--/.nav-collapse --> </div> </div> <div class="container"> <!-- Main component for a primary marketing message or call to action --> <div class="jumbotron"> <h1>Navbar example</h1> <p>This example is a quick exercise to illustrate how the default, static and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p> <p>To see the difference between static and fixed top navbars, just scroll.</p> <p> <a class="btn btn-lg btn-primary" href="../../components/#navbar" role="button">View navbar docs »</a> </p> <p> <ul id="topmenu"> <li><a href="default.php">Add marker</a></li> <li><a href="default2.php">View markers</a></li> </ul> <div id="container"> <div id="mapCanvas"></div> <div id="infoPanel"> <br /> <div id="markerStatus"></div> <div id="info"></div> <div id="geot"></div> <form id="form1" name="form1" action="add.php" method="post"> <input type="hidden" name="newcenter" id="mcenter1" value="mcenter1"> <input type="hidden" name="newzoom" id="mzoom1" value="mzoom1"> <input type="hidden" id="rsLat" name="rsLat" size="18"> <br /> <input type="hidden" id="rsLong" name="rsLong" size="18"> <br /> Name: <input type="text" id="rsname" name="rsPubName"><br /> <b>Category:</b> <select id="rscategory" name="rscategory"> <option id="GreatView" value="Great View">Great view</option> <option id="cafe" value="Cafe">Cafe</option> <option id="pub" value="Pub">Pub</option> <option id="restaurant" value="Restaurant">Restaurant</option> <option id="theatre" value="Theatre">Theatre</option> <option id="venue" value="Venue">Venue</option> <option id="landmark" value="Landmark">Landmark</option> <option id="poi" value="Place of Interest">Place of Interest</option> <option id="hiddenmsg" value="Hidden Message">Hidden Message</option> <option id="secretspot" value="Secret Spot">Secret Spot</option> <option id="hiking" value="Hiking">Hiking</option> <option id="hiking" value="Camping">Camping</option> <option id="dogfriendly" value="Dog Friendly">Dog Friendly</option> <option id="valueformoney" value="Value for money">Value for money</option> <option id="streetview" value="Street View">Interesting street view</option> </select> <br /> Description: <textarea id="desc" name="rsdesc" ></textarea> Address: <textarea id="address" name="rsAddress" ></textarea> <input type="hidden" id="wlat" name="rslat" size="10"><br /> <input type="hidden" id="wlon" name="rslng" size="10"><br /> City: <textarea id="city" name="rsTown" ></textarea><br /> <textarea id="country" name="rsCounty" ></textarea><br /> <div class="telephone"> Telephone: <input type="text" name="rsTel"> </div> <div class="website"> Website: <input type="text" name="rsWebsite"> </div> <input type="submit" name="submit" value="Pin Your Location"> </form> <br /><br /> <!-- <b>Current map center:</b> <div id="mcenter"></div> <div style="float:left;"><b>Current map zoom level: </b></div><div id="mzoom" style="float:left;"></div> <div style="clear:both;"></div> --> <!-- <form id="form2" name="form2" method="post" action="center.php"> <input type="hidden" name="newcenter" id="mcenter2" value="mcenter2"> <input type="hidden" name="newzoom" id="mzoom2" value="mzoom2"> <input type="submit" name="submit" value="Center Marker On Map"> </form> <div style="width:300px; font-size:10pt; color:#999; text-align:justify;">'Center Marker On Map' ... This uses cookies to remember location and zoom level.</div> --> </div> </div> </p> </div> </div> <!-- /container --> <script src="../../dist/js/bootstrap.min.js"></script> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <script src="js/ie10-viewport-bug-workaround.js"></script> </body> </html> Hello, I'm more looking for advice but any helpful examples would be great. So basically what I need to accomplish is a grid, that I can drop objects into, then save the coordinates. So let's say I have a 3x3 set of tiles which will represent "floor tiles", and I load from my MySql database a users "furniture", what's the best method of being able to take these dynamic items drop them on a tile which can be then saved in an xml file or something. What are the best j/s libraries for this? I know jQuery and mootools have drag and drop functions but can they accomplish what I'm looking for? Any feedback will help, I'm comfortable coding in js but I want to do it effeciently and there's got to be people who have done similar things. Hi everyone In this snippet the addresses stored in address[] is geocoded using google maps API. The problem comes when i try to pass these values on to the array flightPlanCoordinates to create a polyline. Nothing happens. Can anyone tell me why? PS. Im quite new to JS Code: var flightPlanCoordinates = []; for ( var i=0, len=address.length; i<len; ++i ){ geocoder.geocode( { 'address': address[i]}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { flightPlanCoordinates.push( new google.maps.LatLng( parseFloat(results[0].geometry.location.lat()), parseFloat(results[0].geometry.location.lng()) ) ); } }); } var flightPath = new google.maps.Polyline({ path: flightPlanCoordinates, strokeColor: "#000000", strokeOpacity: 1.0, strokeWeight: 3 }); flightPath.setMap(map); I search through the forums and google but didn't find anything on this, but I was wondering if anyone was having or has had issues with google maps changing their lat/long coordinates, even when a frozen version is declared? Code: <script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script> In the geocoding portion: Code: geocoder.geocode({'address': query}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var coordinates = results[0].geometry.location; point.latitude = coordinates['oa']; point.longitude = coordinates['pa']; return callback(); } else { var error = new Object(); error.message = 'We were unable to locate your latitude and longitude. Please check your address and try again.<br />'; error.callback = function(){}; return point.errorHandler(error); } }); The coordinates variable keeps changing the key. Originally it was: Code: point.latitude = coordinates['xa']; point.longitude = coordinates['ya']; Then: (and several others) Code: point.latitude = coordinates['sa']; point.longitude = coordinates['ta']; Now: Code: point.latitude = coordinates['oa']; point.longitude = coordinates['pa']; Why if a frozen version is declared, is this still changing? This is what my code is supposed to do: 1. create a select list that changes the photo showing, (which I have) 2. create script so that when the user hovers over the image it shows a div 3. when the users mouse is off the image/div shows the coordinates where it last left 4. on mouseout hides the div again (this is the part I'm stuck on) This is my html: Code: <style> #selectdiv { position:absolute; left:10px; top:10px; width:400px; height:400px; } #mylist { position: absolute; left: 200px; top: 100px; width:inherit; height:inherit; } #myyellow { position: absolute; left: 600px; top: 100px; width:300px; height:200px; background-color:#FF3; } </style> <body> <div id="selectdiv"> <h1 style="font-size:28px">Select a Beatle</h1> <select name="beatles" size="1" id="myselect" onchange="showDiv();"> <option value="-">-</option> <option value="J">John</option> <option value="P">Paul</option> <option value="G">George</option> <option value="R">Ringo</option> </select> </div> <div id="mylist" style="display:none" onmouseover="showYellow(event);" onmouseout="showpixels(event)"></div> <div id="John" style="display:none"> <img src="beatles_john.jpg" /> </div> <div id="Paul" style="display:none"> <img src="beatles_paul.jpg" /> </div> <div id="George" style="display:none"> <img src="beatles_george.jpg" /> </div> <div id="Ringo" style="display:none"> <img src="beatles_ringo.jpg" /> </div> <div id="myyellow" style="display:none"></div> <div id="msg"></div> </body> This is my script: Code: function showDiv() { var mySelect = document.getElementById("myselect"); var myList = document.getElementById("mylist"); switch (mySelect.value) { case 'J': myDiv = document.getElementById("John"); myList.innerHTML = myDiv.innerHTML; myList.style.display = "block"; //Makes div viewable break; case 'P': myDiv = document.getElementById("Paul"); myList.innerHTML = myDiv.innerHTML; myList.style.display = "block"; //Makes div viewable break; case 'G': myDiv = document.getElementById("George"); myList.innerHTML = myDiv.innerHTML; myList.style.display = "block"; //Makes div viewable break; case 'R': myDiv = document.getElementById("Ringo"); myList.innerHTML = myDiv.innerHTML; myList.style.display = "block"; //Makes div viewable break; } } function showYellow(event) { var myyellow = document.getElementById("myyellow"); myyellow.style.display = "block"; } function showpixels(event) { x=event.clientX y=event.clientY var myMsg = document.getElementById("msg"); myMsg.innerHTML = "X coords: " + x + ", Y coords: " + y; } Any feed back is greatly appreciated. Hi all, I have a div element (i.e. <div id="main">) that contains a number of links, each with white background colors and its top and left style properties set to different values. I need to do several things with the anchors when they are clicked: When a white anchor is clicked, its background color is turned yellow and its coordinates (top and left style property values) are added to an array. The coordinates for a single anchor is to be separated by a hyphen; coordinates for multiple anchors are to be separated by a comma (eg. "0-9,0-18") When a yellow anchor is clicked, its background color is turned white and its coordinates are removed from the array. The values in the array are to be the value for a hidden input element, all separated by commas. I'm a Javascript novice and don't know where to begin. Can someone help me with this? Thanks in advance, Dude-Dastic Hi guys, Hopefully a really quick question. I'm a JS novice, and am looking for a way to output the coordinates of a Google maps marker into the value of two text fields, one for latitude and one for longitude. The code below is a simple location search which returns a result with a draggable marker. Currently, the coordinates in both text fields update when the location search is performed, but not when the marker is dragged to a new location afterwards. Does anyone know the code to simply update the coordinates each time the marker is dropped on a new location? Code: <html> <head> <style type="text/css"> #map_canvas { width:444px; height:444px; overflow:hidden; } </style> <script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAA-Kl-tQOj5PlnOlXQmp2N9hTg6Fn61x9hOlvMvn6kV4ENK8yRfBShRuj-nulocuk2Alx9JmFKKV4zwA" type="text/javascript"></script> <script type="text/javascript"> var map; var geocoder; function initialize() { map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(52.8068752, -1.6430344),6); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.enableScrollWheelZoom(); geocoder = new GClientGeocoder(); // Update current position info } // addAddressToMap() is called when the geocoder returns an // answer. It adds a marker to the map with an open info window // showing the nicely formatted version of the address and the country code. function addAddressToMap(response) { map.clearOverlays(); if (!response || response.Status.code != 200) { alert("Whoops, we couldn't find that address!"); } else { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); marker = new GMarker(point,{draggable:true}); map.addOverlay(marker); marker.openInfoWindowHtml(place.address + '<br /><span class="smallgrey">Zoom in and drag the marker to exactly where the point is</span>'); document.getElementById("latitude").value = point.lat(); document.getElementById("longitude").value = point.lng(); } } // showLocation() is called when you click on the Search button // in the form. It geocodes the address entered into the form // and adds a marker to the map at that location. function showLocation() { var address = document.forms[0].q.value; geocoder.getLocations(address, addAddressToMap); } // findLocation() is used to enter the sample addresses into the form. function findLocation(address) { document.forms[0].q.value = address; showLocation(); } </script> </head> <body onload="initialize()"> <form action="#" onsubmit="showLocation(); return false;"><input type="text" name="q" size="35" /> <input type="submit" name="find" value="Search"/></form> <div id="map_canvas">And pin the <strike>tail</strike> marker on the <strike>donkey</strike> map:<br /></div> Latitude: <input class="required" type="text" name="latitude" id="latitude" value="53.34870686020199" /> <br /> Longitude: <input class="required" type="text" name="longitude" id="longitude" value="-6.267356872558594" /> </body> </html> Many thanks in advance, I appreciate anyone who wants to help out! I am trying to create a mobile safari compatible "slide to unlock" type deal, like the one on jailbreakme.com, i have found many that are compatible with google chrome, or firefox, but none with mobile safari, any help?
I want to Create a simple scanner app for the iPhone so when someone scans a URL embedded in a QR code, it opens the browser and loads that URL.
I've put together a couple of scripts, in order that I can make an image move left or right on the x-axis, depending on the LR (left/right) read-out from the accelerometer of an iPhone. However, it's not working at the moment, so could anyone possibly see what I've missed out - I've worked on it that long, that I think I'm missing something obvious!! THANKS!! Code: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>onlywebpro.com</title> </head> <body> <h2>Device Orientation with HTML5 | onlywebpro.com</h2> <img src="Car4.png" id="car" style="position:relative;top:200px;left:200px; "><br> <script type="text/javascript"> if (window.DeviceOrientationEvent) { console.log("DeviceOrientation is supported"); window.addEventListener('deviceorientation', function(eventData) { var LR = eventData.gamma; deviceOrientationHandler(LR); var userWidth = window.screen.width; function moveRight() { var pp = document.getElementById("car"); var lft = parseInt(pp.style.left); var tim = setTimeout("moveRight()",50); // 50 controls the speed lft = lft+LR; // move by 50 pixels pp.style.left = lft+"px"; if (lft > userWidth + 439) { // left edge of image past the right edge of screen pp.style.left = -400; // back to the left clearTimeout(tim); } } }, false); } else { alert("Not supported on your device or browser. Sorry."); } var userWidth = window.screen.width; function moveRight() { var pp = document.getElementById("car"); var lft = parseInt(pp.style.left); var tim = setTimeout("moveRight()",50); // 50 controls the speed lft = lft+LR; // move by 50 pixels pp.style.left = lft+"px"; if (lft > userWidth + 439) { // left edge of image past the right edge of screen pp.style.left = -878; // back to the left clearTimeout(tim); } } </script> </body> </html> This is for an iphone app using html5, css3 and javascript with phonegap to embed. The app runs on mobile safari. I have a list page [ list.html ] . Clicking on a list item takes the user to a specific page for that item [ e.g. item1.html ]. On item1.html page a question is answered in a form box. This is processed using a simple pasuser script which works fine. I need to add a script so that when a correct answer is given on item1.html a small graphic appears next to to the item listed on list.html. Even though item1.html can be accessed again later, the small graphic must always remain next to the listing. All help much appreciated. I am not a programmer but can understand the arguments. Thanks. hi, I am trying to redirect from my main site to my mobile site by detecting screen width using javascript. But everything time i try to test this via the iphone 4s,the browser keeps reloading without loading any content, like its on some sort of loop! Here are the scripts ive tried to used below, have i missed anything? [CODE] <script type="text/javascript" charset="utf-8"> if (navigator.userAgent.match(/(operamini|ipad|ipod|iphone|android|webOS|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafon e|o2|pocket|kindle|mobile|hiptop|\bpda|psp|treo|nokia|blackberry)/i)) { location.replace("example.com"); } </script> [CODE END] [CODE] <script type="text/javascript"> if (screen.width <= 550) window.location = 'http://yoursite.com/mobile'; </script> [CODE END] Thanks in advance for any help! Jon Hi Guys, I've been searching the net for both examples and pluggins to create draggable divs and although I've found many, I cant find the effect I'm after. I want the div to slow down to a stop after it has been release like when you are scrolling on one of apples mobile devices. If anybody can point me in the right direction ill be very great full. I'm working on this project: http://bit.ly/tkrFsP It already works more or less fine in: IE7, IE8, IE9, FF, Chrome, Safari and Opera. Problems start when we try that in iPhone or iPad. iPhone works almost fine (except lags and AJAX/jQuery problems) but in iPad it has broken left navigation, wrongly re-sized thumbnails and it displays in half of the viewport. Also, there are problems with smoothness of jQuery animations and with AJAX unlike in other browsers on other devices (like PC). Any ideas on how to fix that? I've flicked through this: 1. http://www.smashingmagazine.com/2010...tting-started/ 2. http://developer.apple.com/library/s...62/_index.html It seems like a good place to start but there's many information on iPad/iPhone development on apple.com and their solutions don't fix my problems. -------- Mo 1. Anyone could outline here some basic code principles for iPad/iPhone? 2. Why project sub-page displays 5 times as large as it should on iPhone? Adding this: <meta name="viewport" content="width=device-width" /> doesn't help much and it even makes website work worse. Adding this: <meta name="viewport" content="maximum-scale=1,user-scalable=yes,width=960" > seems like a better solution but it's not perfect either. 3. How iPad's fixed containers work? 4. Why there's horizontal scroll appearing even with overflow-x: hidden? Hi On the following URL on the iphone and Ipad the jqzoom script is showing the enlarged image on the left but works fine in IE, Chrome, Firefox etc. The script in use is jqzoom. http://tinyurl.com/bwcxf8c Any idea welcome. Thanks Roy I have a video on a page, which on a pc or mac, will play inside a standard flash player. On the iphone, I have setup javascript to detect iphone / ipod, and replace the flash player with an embedded m4v file: Code: if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { $('div#vid').empty(''); $('div#vid').html('<div ontouchstart="incrementHitcount()"><embed src="http://www.gridcity.co.nz/uploaded/images/'+cid+'_bg.jpg" href="http://www.gridcity.co.nz/uploaded/videos/'+cid+'.m4v" type="video/x-m4v" rel="nofollow" target="myself" width="'+vidwidth+'" height="'+vidheight+'" scale="1" id="iphone"></embed><div>'); } So far so good. I also want to trigger a simple onclick which makes an ajax call a remote PHP file. I have tried ontouchstart instead (see above code) but still no luck. If I add the onclick to a static image rather than an embed instance, it works fine. But with the embedded video, it's as if the video blocks the onclick event for javascript to pickup. Does anyone know a way around this? Hello I'm having problems with a very simple bit of Javascript not working with the latest version of Safari for ipads and iphones. The script in question is used as a 'previous image ' and 'next image' navigation facility, basically closing one pop-up window and opening up another, when viewing a photo gallery. It has worked perfectly for a number of years on all browsers. It is only the latest version of Safari for ipads and iphones where there's a problem. On an iphone, the new window unfortunately opens up in a new tab and the existing window fails to close. Mobile Safari soon reaches the maximum of 8 permissible tabs as a user moves through the photos gallery. On an ipad2, no new window opens and the existing window fails to close. the website is www.gethigh.co.uk Code: } function picPopup4(page,width,height){ //alert(scroll); var a; a = width / 2; var b; b = height / 2; var LeftPosition = (screen.width/2) - a; var TopPosition = (screen.height/2) - b; window.open(page, "", "width="+width+",height="+height+",toolbar=no,header=no,location=no,resizable=yes,"+"left="+LeftPosition +",top="+TopPosition+",scrollbars=yes"); window.close(); } and this is an example of the code creating the navigation within each pop-up window Code: <tr> <td align="center"><a class="link8" href="javascript:picPopup4('legslip1.html','560','770');" target="_self"> previous image</a> <a class="link8" href="javascript:window.close()">close window</a> <a class="link8" href="javascript:picPopup4('breaking2.html','505','800');" target="_self">next image</a></td> </tr> I'll come clean and admit I'm not a programmer and have a very basic and ancient understanding of HTML coding. My website must be approaching double digit years old (which will be immediately apparent if you view its structure). I can usually resolve most things, and maintain its functioanality when needs be, but this particular problem has got me stumped. I've come onto this forum to see if anyone could provide a simple work-around ? Or if anyone would know if this is a bug within Safari which may be rectified soon (a search through the Apple forums gave no clues). I'm loathed to make any major updates/changes to my site, as despite its age it renders beautifully on all browsers except the latest ipad/iphone Safari. Cheers and hopefully thanks in advance Garry .... |