嗨有以下jQuery事件:
listItems.on('click', function(ev) {
ev.preventDefault();
reload = true;
var url = jQuery(this).attr('data-url');
history.pushState({}, '', url);
...
}
Run Code Online (Sandbox Code Playgroud)
其中加载通过AJAX动态内容,并推动历史的国家,从修改浏览器的URL www.domain.com来www.domain.com/page-x.通过AJAX加载内容的唯一原因是我需要动画页面过渡.如果你去找www.domain.com/page-x你正常的HTML页面.
如果单击listItem用户单击其浏览器上的后退按钮后,会出现此问题.网址会更改www.domain.com/page-x为www.domain.com,但页面不会重新加载.这就是我添加此事件的原因:
window.onpopstate = function() {
if (reload == true) {
reload = false;
location.reload();
}
}
Run Code Online (Sandbox Code Playgroud)
如果当前页面是通过AJAX加载的,它会在url更改后重新加载页面.它工作正常,但现在我有其他问题:
任何想法/解决方案都将受到高度赞赏.
我刚刚注意到PHP日期函数很奇怪,有人可以解释一下我做错了什么吗?
以下代码显示相同的结果
<?php
echo date('Y-m-t');
// Outputs last day of this month: 2016-03-31
echo date('Y-m-t', strtotime("-1 month"));
// For some reason outputs the same: 2016-03-31
echo date('Y-m-t', strtotime("+1 month"));
// Outputs 2016-05-31
Run Code Online (Sandbox Code Playgroud)
这可能只是我愚蠢,但有人可以解释我为什么会这样吗?
您好我试图用simplexml解析XML.问题是我无法访问atributtes,任何想法为什么?
PHP代码:
$xml = simplexml_load_file($source);
foreach($xml->children() as $node) {
foreach ($node->AttrList->attributes() as $attribute) {
print_r ($attribute);
}
}
Run Code Online (Sandbox Code Playgroud)
一块XML:
<ProductCatalog>
<Product>
<ProductCode>ST905003FND2E1-RK</ProductCode>
<Vendor>SEAGATE</Vendor>
<ProductType>HDD External</ProductType>
<ProductCategory>Cietie diski</ProductCategory>
<ProductDescription>HDD External SEAGATE FreeAgent Go 5400.2 (2.5",500GB,8MB cache,USB 2.0,FreeAgent software) Black</ProductDescription>
<Image>https://www.it4profit.com/catalogimg/wic/1/ST905003FND2E1-RK</Image>
<ProductCard>https://content.it4profit.com/itshop/itemcard_cs.jsp?ITEM=90728055033221913&THEME=asbis&LANG=lv</ProductCard>
<AttrList>
<element Name="Device Location" Value="External"/>
<element Name="Hard Drive Type" Value="Portable"/>
<element Name="Form Factor" Value="2.5""/>
<element Name="Storage Capacity" Value="500000 MB"/>
<element Name="Supports Data Channel" Value="USB 2.0"/>
<element Name="Installed Cache Memory Storage Capacity" Value="8 MB"/>
<element Name="Sector Capacity" Value="512 B"/>
<element Name="Rotational …Run Code Online (Sandbox Code Playgroud)