Tag: 位置

document.URL和location.href之间的区别

我知道document.URL不能被设置,而location.href可以。 但该文件指出: URL是DOM Level 0 location.href属性的替代品。 那么我们什么时候会使用document.URL呢?

在JavaScript中获取数组中的最大值和最小值

我从数据属性创build以下数组,我需要能够从中获取最高和最低的值,以便稍后将其传递给另一个函数。 var allProducts = $(products).children("li"); prices = [] $(allProducts).each(function () { var price = parseFloat($(this).data('price')); prices[price] = price; }); console.log(prices[0]) <!– this returns undefined 我的列表项目看起来像这样(为了可读性,我已经减less了): <li data-price="29.97"><a href="#">Product</a></li> <li data-price="31.00"><a href="#">Product</a></li> <li data-price="19.38"><a href="#">Product</a></li> <li data-price="20.00"><a href="#">Product</a></li> 一个快速的console.log价格显示我的数组似乎是sorting,所以我可以抓住第一个和最后一个元素,我认为,但目前的名称和数组中的值是相同的,所以每当我尝试做一个价格[0 ],我弄不明白 [] 19.38 19.38 20.00 20.00 29.97 29.97 31.00 31.00 有一种感觉,这是一个愚蠢的简单的问题,所以请亲切:)

LocationRequest setInterval(long millis)和LocationRequest setFastestInterval(long millis)之间的区别

我正在编写我自己的背景位置更新每隔5分钟在Android的时间间隔。 我想知道setInterval和setFastestInterval之间的区别 当我将InterInval设置为5分钟并将setFastestInterval设置为2分钟。 位置更新每2分钟一次。 我想知道区别。 我无法理解这个https://developer.android.com/reference/com/google/android/gms/location/LocationRequest.html的开发者页面中究竟写了什么 另外:是否有一个内置的function来检查位置更新只有当第一次更新的距离超过20米与第二次更新? 谢谢!

如何获得国家(或其ISO代码)?

获取国家代码的最佳方式是什么? 到目前为止,我知道两种方法之一是通过TelephonyManager获取,另一种是Locale,这是另一种在android中查找国家/地区代码的最佳方式。

RecyclerView – 在特定位置获取视图

我有一个RecyclerView和一个ImageView 。 我正在使用RecyclerView来水平显示图像列表。 当我点击RecyclerView的ImageView时,活动中的ImageView应该会显示更大的图像。 到目前为止一切正常。 现在活动中还有两个ImageButtons : imageButton_left和imageButton_right 。 当我点击imageButton_left , ImageView中的ImageView应该向左转,而RecyclerView的缩略图也应该反映这个改变。 与imageButton_right类似。 我能够旋转ImageView 。 但是,如何在RecyclerView旋转缩略图? 我怎样才能得到ViewHolder的ImageView ? 码: 活动XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:orientation="vertical"> <ImageView android:id="@+id/original_image" android:layout_width="200dp" android:layout_height="200dp" android:scaleType="fitXY" android:src="@drawable/image_not_available_2" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:gravity="center_horizontal" android:orientation="horizontal"> <ImageButton android:id="@+id/imageButton_left" […]

粘滞边栏:向下滚动时贴在底部,向上滚动时贴在顶部

我一直在寻找一些解决我的粘滞边栏问题的时间。 我有一个特定的想法,我希望如何行动; 有效地,当你向下滚动时,我希望它坚持到底部,然后当你向后滚动时,我想它会以stream畅的运动(不跳跃)粘到顶部。 我无法find我想要达到的一个例子,所以我创造了一个我希望能够更清楚地表明这一点的图像: 侧栏位于标题下。 在向下滚动时,侧边栏与页面的内容保持水平,以便您可以滚动浏览侧边栏和内容。 到达侧边栏的底部,侧边栏粘贴到视口的底部(大多数插件只允许粘贴到顶部,有些粘贴到底部不允许)。 触及底部,侧边栏位于页脚上方。 当您向后滚动时,侧边栏与内容保持水平,因此您可以再次滚动内容和边栏。 到达侧栏的顶部,侧栏粘贴到视口的顶部。 到达顶部和侧边栏位于标题下方。 我希望这是足够的信息。 我创build了一个jsfiddle来testing任何插件/脚本,我已经重置了这个问题: http : //jsfiddle.net/jslucas/yr9gV/2/ . 非常感谢,如果有人有我的解决scheme。

testing链接是否与外部jQuery / JavaScript?

如何testing链接是外部链接还是内部链接? 请注意: 我不能硬编码本地域。 我无法testing“http”。 我可以通过http绝对链接轻松地链接到我自己的网站。 我想使用jQuery / JavaScript,而不是CSS。 我怀疑答案在位置.href,但解决scheme逃避我。 谢谢!

打开位置服务,而不导航到设置页面

与传统的提示用户转到设置页面并启用定位服务并再次返回的方法相反,我注意到在一些最新的应用程序中执行相同的更简单的方法。 参考下面的截图,它会提示一个对话框,用户只需点击一下就可以启用定位服务,并且可以在这些应用程序中运行。 我怎样才能达到相同的?

JavaScript的窗口位置HREF没有哈希?

我有: var uri = window.location.href; 这提供了http://example.com/something#hash 没有#hash的整个path的最好和最简单的方法是#hash ? uri = http://example.com/something#hash nohash = http://example.com/something 我尝试使用location.origin+location.pathname这不适用于每个浏览器。 我尝试使用location.protocol+'//'+location.host+location.pathname这看起来像一个糟糕的解决scheme给我。 什么是最好的和最简单的方法呢? 也许我查询location.hash并尝试从uri substr()这?

window.location与只是位置

在整个networking中,我看到大量的JavaScript程序员编写window.location而不是location 。 我很好奇,如果有人能够提供一个解释,为什么。 window是全局对象,因此没有必要包含 – 不是吗? 我的意思是,你没有看到人写new window.Date()或new window.Date() ,所以我很好奇,为什么它将与location指定。 我明白, location被认为是你所在的窗户的“财产”,我认为这是有道理的。 但即便如此,我也没有看到任何理由来指定全局对象。 首先不可能覆盖location ,而不是不redirect页面。 那么,这只是一个已经被使用了很长时间的怪癖,它已经和我们写JavaScript的方法结合起来了,还是有一些这样做的有形的理由? 我检查了谷歌,但唉,我什么都没有想出来…