我想通过单击基于用户位置的按钮将用户重定向到特定的HTML文件。 具体来说-我想在单击按钮时获取它们的位置,然后将其重定向到正确的HTML文件。
我从w3c学校获得了此代码,但是我不知道下一步该怎么做。
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(pos) {
//You have your locaton here
console.log("Latitude: " + pos.coords.latitude +
"Longitude: " + pos.coords.longitude);
});
} else {
console.log("Geolocation is not supported by this browser.");
}
}
<button onclick="getLocation()">Get Location</button>
答案 0 :(得分:1)
您可以使用:
---------------------------------------------------------------------------
SympifyError Traceback (most recent call last)
<ipython-input-31-26c783d64bc7> in <module>()
6 equats[i-1] = equat.subs({l : a*i*1/4})
7 print(equats)
----> 8 plot_implicit(equats, (x, -5,5), (y, -5, 5))
~\Anaconda3\lib\site-packages\sympy\plotting\plot_implicit.py in plot_implicit(expr, x_var, y_var, **kwargs)
316
317 elif not isinstance(expr, Relational):
--> 318 expr = Eq(expr, 0)
319 has_equality = True
320 elif isinstance(expr, (Equality, GreaterThan, LessThan)):
~\Anaconda3\lib\site-packages\sympy\core\relational.py in __new__(cls, lhs, rhs, **options)
290 from sympy.simplify.simplify import clear_coefficients
291
--> 292 lhs = _sympify(lhs)
293 rhs = _sympify(rhs)
294
~\Anaconda3\lib\site-packages\sympy\core\sympify.py in _sympify(a)
385
386 """
--> 387 return sympify(a, strict=True)
388
389
~\Anaconda3\lib\site-packages\sympy\core\sympify.py in sympify(a, locals, convert_xor, strict, rational, evaluate)
301
302 if strict:
--> 303 raise SympifyError(a)
304
305 try:
SympifyError: SympifyError: [0.0625*y**2 - (x**2 + y**2)*(y + 1)**2, 0.25*y**2 - (x**2 + y**2)*(y + 1)**2, 0.5625*y**2 - (x**2 + y**2)*(y + 1)**2, 1.0*y**2 - (x**2 + y**2)*(y + 1)**2, 1.5625*y**2 - (x**2 + y**2)*(y + 1)**2, 2.25*y**2 - (x**2 + y**2)*(y + 1)**2, 3.0625*y**2 - (x**2 + y**2)*(y + 1)**2, 4.0*y**2 - (x**2 + y**2)*(y + 1)**2]
或:
window.location.replace("http://example.com");
在javascript函数中获得位置(纬度和经度)后
答案 1 :(得分:0)
为按钮提供一个ID,然后在脚本中执行类似的操作。
<script type="text/javascript">
document.getElementById("myButton").onclick = function () {
location.href = "www.site123.com";
};
</script>
并根据纬度和经度变量在函数中添加if语句