我花了两个多月的时间试图解决这个编码问题.首先,我知道JavaScript在客户端运行,PHP在服务器上运行.
我有两个PHP页面(index23.php和index24.php),都使用HTML/PHP和JS.
我正在使用HTML5地理位置API:
<body onload="getLocation()">
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else
{
x.innerHTML="Geolocation is not supported by this browser.";
}
}
function showPosition(position)
{
x.innerHTML= "+" + position.coords.latitude + "+" + position.coords.longitude;
}
</script>
Run Code Online (Sandbox Code Playgroud)
我可以在当前的PHP页面(index23.php)上看到地理编码值.然后我单击一个HTML表单按钮,浏览器转到另一个页面(index24.php).
如何使用表单上的提交按钮将第一个PHP页面上的JavaScript值传递到第二个PHP页面?
这是我的表格:
<form id="searchbox" action="index24.php" method="get">
<input name="q" type="text" placeholder="Type here"/>
<input id="submit" type="submit" value="Search"></form>
Run Code Online (Sandbox Code Playgroud) 我有一个HTML5网页,我想使用webview for Android DSK.
这是我的androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.myfirstapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
这是我在布局文件夹上的activitymain.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我还该怎么办?那个代码放在哪里?
谷歌android文档说这个:
要在WebView中加载网页,请使用loadUrl().例如:
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.example.com");
Run Code Online (Sandbox Code Playgroud)
但是我应该在哪里放置这些代码?在新文件中?我尝试了很多没有成功的事情.