仅在首次访问时显示>if(!localStorage.getItem(“runOnce”)){触发锚链接
Display only on first visit > if( ! localStorage.getItem( "runOnce" ) ) { trigger anchor link
我有一个javascript表单,可以进行一些计算,但只想在访问者第一次进入网站时显示。
我试图在我的代码之前添加
jQuery(document).ready(function($) {
if( ! localStorage.getItem( "runOnce" ) ) {
我需要触发一个链接,而不是runOnce。你能就如何做到这一点提出建议吗???我从0开始学习…感谢
data-slide
标记是特定JS脚本的自定义标记。当然,这是在网站中产生"滑动"效果的代码。我一直在查看网站。使用"关于"按钮
您有一个滑动到容器834的about按钮。将id about-btn
添加到其中,如下所示:
<a id="about-btn" href="http://www.inlovewithdeath.com/about-satish-modi-the-author/" class="menu-item menu-item-type-post_type menu-item-object-page" data-slide="container-834" data-name="about-satish-modi-the-author">About</a>
现在将其添加到某个地方,很可能是在外部脚本中,然后将其包括在内:
// shortcut of $(document).ready().
$(function() {
// check if runOnce exists, if not run the block.
if (! localStorage.getItem('runOnce')) {
// we set the runOnce, so this block doesn't run on the second time.
localStorage.setItem('runOnce', '1');
}
else
{
// The item exists and set!!
// Now we will simulate a click on the about button.
// Which should move the user to your spot with your code.
$('#about-btn').click();
}
});
我建议先学习纯/香草JS,然后再使用框架来了解一切工作原理。
// force the form identified as id=myform to submit
$("#myform").submit();
// or click the submit button on the form
$("#mysubmitbutton").click();
submit():http://api.jquery.com/submit/单击():http://api.jquery.com/click/
相关文章:
- 为什么localStorage[“..”]未定义,而localStorage.getItem(“..”)为null
- 无法访问localStorage.getItem(JSONObj)的值
- AngularJS "localStorage.getItem" is null in $resou
- 使用回调从dynamodb.getItem()返回数据
- d3 localStorage.getItem() compare arrays .filter()
- img src="localStorage.getItem('icon')"?
- SVG <g> selection with localStorage.getItem()
- localStorage.getItem() 在不同的浏览器中给出不同的结果
- 高级闭包兼容性和静态类型 - 使用未定义类型和全局函数,如localStorage.getItem();
- 使用localStorage.getItem()获取differents属性的值
- 以字母或数字顺序排列localStorage getItem
- localStorage.getItem返回IE 9中的旧数据
- localStorage getItem不能很好地工作
- sessionStorage javascript, load getItem?
- window.sessionStorage.getItem('anyItem')容易受到客户端DOM存储
- dynamoDB:如何使用dynamoDB . getitem返回的值
- 错误:getItem()方法不存在(Angular, mocking LocalStorage)
- RunOnce for javascript On page Post back.?
- 仅在首次访问时显示>if(!localStorage.getItem(“runOnce”)){触发锚链接
- Count Up window.localStorage.getItem via Javascript