如何在jquery mobile中重新加载页面?

时间:2012-10-31 06:59:17

标签: php jquery-mobile

在我的项目中,我正在使用一些javascript来实现我的工作,但是当我启动页面时它没有采取,但是在重新加载页面后它正在工作。

以下是代码:

<?php 
require_once"session.php";
$slat =$_GET['slat'];
$slang =$_GET['slang'];
$elat =$_GET['elat'];
$elang =$_GET['elang'];
?>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <?php require_once"header.php";?>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <title>Near My Location Contacts</title>
    <script src="http://maps.google.com/maps/api/js?sensor=false"
            type="text/javascript"></script>
    <script type="text/javascript">
   /* function refreshPage() {
        alert('dfg');
    window.location.href,
    {
      allowSamePageTransition : true,
      transition              : 'none',
      showLoadMsg             : false,
      reloadPage              : true
    }
}
refreshPage();*/
    //<![CDATA[
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
//var haight = new google.maps.LatLng(37.7699298, -122.4469157);
//var oceanBeach = new google.maps.LatLng(37.7683909618184, -122.51089453697205);
var haight = new google.maps.LatLng(<?php echo $slat;?>,<?php echo $slang;?>);
var oceanBeach = new google.maps.LatLng(<?php echo $elat;?>,<?php echo $elang;?>);
function initialize() {
  directionsDisplay = new google.maps.DirectionsRenderer();
  var mapOptions = {
    zoom: 14,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    center: haight
  }
  map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
  directionsDisplay.setMap(map);
  directionsDisplay.setPanel(document.getElementById("directionsPanel"));
}

function calcRoute() {
  var request = {
    origin:haight,
    destination:oceanBeach,
    travelMode: google.maps.TravelMode.DRIVING,
    unitSystem: google.maps.UnitSystem.METRIC
  };
  directionsService.route(request, function(response, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      directionsDisplay.setDirections(response);
    }
  });
}

    //]]>
  </script>
  </head>
  <body style="margin:0px; padding:0px;" onload="initialize();calcRoute()"> 
  <div data-role=page id=nmContacts >
    <div data-role=header data-theme="e" >
        <a href="geoMapGrid.php" data-icon="back" ><font size="2px">Back</font></a>
        <h1 align="left"><font size="2px">Near My Contacts</font></h1>
    </div>
  <div data-role=content style="width:100%;height:100%;">
  <div data-role=content id="map_canvas" style="width:95%; height:300px"></div>
<div id="directionsPanel" style="width:97%;height 100%"></div>

</div>

  </body>
</html>

在上面我有身体上载它是第一次没有工作后刷新只是它正在工作....

1 个答案:

答案 0 :(得分:0)

以下是答案:

      Before You are calling to this page You have to specify in href like the following

假设您要加载以下链接:

<a href="sample.php" rel="external">sample</a>

这里`href =“外部”你必须另外指定它不会工作.....