是否有一个函数可以调用以防止浏览器在更改哈希值时记录后面的历史记录条目?
我正在编写一个简单的JavaScript库,当用户浏览每个图像时,它会更改浏览器URL而无需重新加载页面.
这可以通过将location.hash设置为图像的唯一ID来完成.
window.location.hash = imageID;
Run Code Online (Sandbox Code Playgroud)
问题是当用户点击浏览器后退按钮时,他们必须向后移动每个图像,就像页面加载一样.
如果他们使用图库旋转了20张图像,则必须再次单击21次才能返回上一页.
如何防止使用javascript记录回溯历史记录?
当用户使用HTML5 popstate处理程序在浏览器历史记录中导航回来时,我正在尝试检索滚动位置.
这是我有的:
$(document).ready(function () {
$(window).on('popstate', PopStateHandler);
$('#link').click(function (e) {
var stateData = {
path: window.location.href,
scrollTop: $(window).scrollTop()
};
window.history.pushState(stateData, 'title', 'page2.html');
e.preventDefault();
});
});
function PopStateHandler(e) {
alert('pop state fired');
var stateData = e.originalEvent.state;
if (stateData) {
//Get values:
alert('path: ' + stateData.path);
alert('scrollTop: ' + stateData.scrollTop);
}
}
<a id="link" href="page2.html"></a>
Run Code Online (Sandbox Code Playgroud)
当我向后导航时,我无法检索stateData的值.
我认为这是因为popstate正在检索初始页面加载的值,而不是单击超链接时我推送到历史记录的状态.
我怎么能在导航回来时获得滚动位置?
在ios7上检测移动游猎的官方方法是什么?
例如:
navigator.userAgent.match(/(iPod|iPhone|iPad)/)
&& navigator.userAgent.match(/AppleWebKit/)
&& navigator.userAgent.match(/OS 7/)
Run Code Online (Sandbox Code Playgroud) 我刚刚下载了适用于iPad的谷歌浏览器,我注意到它不适用于ASP.NET 4网站!
例如,创建一个简单的页面:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub LinkButton1_Click(sender As Object, e As System.EventArgs)
Response.Write("Link button was clicked")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
</div>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
现在尝试单击链接按钮,但它不会触发回发事件.
我似乎无法调试,因为没有javascript控制台来找出发生了什么.
!更新!!
我发现您需要从Chrome中的设置下拉菜单中选择" 请求桌面版网站"才能使其生效.
!更新!!
ASP.NET无法识别某些浏览器的最新版本,因此会将它们视为低级浏览器.(基本上:没有JavaScript.)修复是获取更新的浏览器定义文件.
我们在哪里可以获得Chrome的更新浏览器定义文件?
我正在尝试将存储帐户映射到Azure中的虚拟机.
我正在按照一个简单的教程详细介绍如何从VM内部访问Azure文件.
您只需创建一个新的存储帐户,以便它具有新的Azure文件访问权限,然后使用net use将驱动器映射到VM:
net use z: \\tempstorage.file.core.windows.net\upload /u:tempstorage mykey
Run Code Online (Sandbox Code Playgroud)
我正进入(状态:
System error 53 has occurred.
The network path was not found.
Run Code Online (Sandbox Code Playgroud)
我公开了容器,可以通过url访问位于里面的文件:
https://tempstorage.blob.core.windows.net/upload/example.jpg
Run Code Online (Sandbox Code Playgroud)
任何想法为什么我得到系统错误53?
请注意:以上网址是示例,不会链接到阅读位置.
我正在为我们的Web应用程序使用 IIS 8 的新应用程序初始化功能.
一切都设置正确,我们第一次访问网站时,我们在web配置中定义了startup.html:
<applicationInitialization
remapManagedRequestsTo="/startup.html"
skipManagedModules="true" >
<add initializationPage="/" />
</applicationInitialization>
Run Code Online (Sandbox Code Playgroud)
问题是,startup.html页面返回HTTP状态代码200!
这意味着对于SEO,谷歌和其他搜索引擎可能会抓取startup.html页面而不是主页,如果在应用程序尚未初始化时索引网站.
当然响应代码应该是:
503 - the server is temporarily unavailable
Run Code Online (Sandbox Code Playgroud)
有没有办法更改静态HTML页面的响应代码?
(注意:这不能通过代码完成,因为ASP.NET管道会正在进行中)
如何将简单的字符串列表绑定到转发器?
Protected Sub Page_Load(sender As Object, e As System.EventArgs)
'create sample data:
Dim photos As New List(Of String)
photos.Add("large1.jpeg")
photos.Add("large2.jpeg")
photos.Add("large3.jpeg")
photos.Add("large4.jpeg")
photos.Add("large5.jpeg")
'bind data:
Repeater1.DataSource = photos
Repeater1.DataBind()
End Sub
Run Code Online (Sandbox Code Playgroud)
HTML简单地说:
<asp:Repeater ID="Repeater1" runat="server" ClientIDMode="Predictable">
<HeaderTemplate><ul></HeaderTemplate>
<FooterTemplate></ul></FooterTemplate>
<SeparatorTemplate>
<li>
<asp:Image ID="img_photo" runat="server" ImageUrl="<%# Container.DataItem %>" /></li>
</SeparatorTemplate>
</asp:Repeater>
Run Code Online (Sandbox Code Playgroud)
Container.DataItem中的值始终为空.
有任何想法吗?
如何从 healthkit 数据中获取最新的体重条目?
我的代码只返回有史以来记录的第一个重量条目。
是否可以仅获取记录的最后一个条目而不指定日期范围?
这是我获取第一个条目的代码:
class HealthStore {
private let healthStore = HKHealthStore()
private let bodyMassType = HKSampleType.quantityType(forIdentifier: .bodyMass)!
func authorizeHealthKit(completion: @escaping ((_ success: Bool, _ error: Error?) -> Void)) {
if !HKHealthStore.isHealthDataAvailable() {
return
}
let readDataTypes: Set<HKSampleType> = [bodyMassType]
healthStore.requestAuthorization(toShare: nil, read: readDataTypes) { (success, error) in
completion(success, error)
}
}
//returns the weight entry in Kilos or nil if no data
func bodyMassKg(completion: @escaping ((_ bodyMass: Double?, _ date: Date?) -> Void)) {
let query = …
Run Code Online (Sandbox Code Playgroud) 我按照MS说明下载并安装了Azure Powershell:https: //azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/
使用Windows Powershell ISE我运行命令:
登录-AzureRmAccount
返回错误:
Login-AzureRmAccount : The 'Login-AzureRmAccount' command was found in the module 'AzureRM.Profile', but the module could not be loaded. For more information, run 'Import-Module AzureRM.Profile'. At line:1 char:1
+ Login-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Login-AzureRmAccount:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
Run Code Online (Sandbox Code Playgroud)
导入模块AzureRM.Profile
返回此错误:
Import-Module : File C:\Program Files (x86)\Microsoft
SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Profile\CheckVersions.ps1 cannot be loaded
because running scripts is disabled on this system. For more information, see about_Execution_Policies at
http://go.microsoft.com/fwlink/?LinkID=135170.
At …
Run Code Online (Sandbox Code Playgroud) 我无法在firefox或IE上访问超链接
如果我设置了a:的背景颜色,它会正常工作,但不会设置优先级.
有任何想法吗?
这是我的css:
a.photo
{
display: inline-block;
}
a.photo img
{
border: 1px solid #C8C8C8;
background-color: #ffffff;
}
a:hover.photo img,
a:active.photo img {
background-color: #FF2D59;
border: 1px solid #FF2D59;
}
a:visited.photo img
{
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
}
a.small img
{
width: 80px;
height: 80px;
padding: 6px;
}
<a href="#" class="photo small">
<img src="http://www.w3schools.com/css/klematis.jpg" alt="small photo hyperlink" />
</a>
Run Code Online (Sandbox Code Playgroud)
我不认为CSS的顺序有什么问题,因为如果我添加背景颜色,它工作得很好:
a:visited.photo img
{
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */ …
Run Code Online (Sandbox Code Playgroud)