在html表单中插入GeoIP城市

Insert GeoIP City into html form

本文关键字:GeoIP 城市 插入 html 表单      更新时间:2023-09-26

已搜索,但找不到此问题的答案。我不是一个程序员,对javascript知之甚少。希望这里有人能帮我。我需要获取用户的地理位置城市,然后将其作为值插入到表单中。我有这个获取地理位置城市的脚本。。。

<script src="http://j.maxmind.com/app/geoip.js"></script>
<script type="text/javascript">document.write(geoip_city());</script>

我需要将该城市纳入表格的价值部分

有什么想法吗?

表单看起来像这样。。。

<input type="hidden" name="custom_City" id="city" value="NEED CITY IN HERE"></input>

之后,标记使用以下脚本:

document.getElementById("city").value = geoip_city();

您给出了错误的live-js路径,应该是这样的http://js.maxmind.com/js/geoip.js