上次在《instantclick 实现的全站无刷新》中大致说了一下实现方式,但是随着大家对文章的关注,我发现有些细节被我遗漏了,同时也发现了存在的问题,下面就接着上篇文章在说一说。
搜索功能这样的非超链接怎么实现不刷新
上篇文章的代码不兼容火狐浏览器,所以将上篇文章中提到的这个代码
$.extend({
getKey: function() {
if(event.keyCode==13){
$('#soux').get(0).click();
}
},
})
改为
$.extend({
getKey: function() {
var theEvent = window.event || arguments.callee.caller.arguments[0];
var code = theEvent.keyCode;
if(code == 13){
$('#soux').get(0).click();
}
},
})
instantclick的情况添加ajax评论
需要将typecho的模板header.php中的
<?php $this->header('); ?>
改成
<?php $this->header('commentReply='); ?>
干掉模板自动输出的评论相关的js代码
然后手动将刚刚屏蔽的代码加入到comments.php里面
<script type="text/javascript">
(function () {
window.TypechoComment = {
dom : function (id) {
return document.getElementById(id);
},
create : function (tag, attr) {
var el = document.createElement(tag);
for (var key in attr) {
el.setAttribute(key, attr[key]);
}
return el;
},
reply : function (cid, coid) {
var comment = this.dom(cid), parent = comment.parentNode,
response = this.dom('<?php echo $this->respondId(); ?>'),
input = this.dom('comment-parent'),
form = 'form' == response.tagName ? response : response.getElementsByTagName('form')[0],
textarea = response.getElementsByTagName('textarea')[0];
if (null == input) {
input = this.create('input', {
'type' : 'hidden',
'name' : 'parent',
'id' : 'comment-parent'
});
form.appendChild(input);
}
input.setAttribute('value', coid);
if (null == this.dom('comment-form-place-holder')) {
var holder = this.create('div', {
'id' : 'comment-form-place-holder'
});
response.parentNode.insertBefore(holder, response);
}
comment.appendChild(response);
this.dom('cancel-comment-reply-link').style.display = '';
if (null != textarea && 'text' == textarea.name) {
textarea.focus();
}
return false;
},
cancelReply : function () {
var response = this.dom('<?php echo $this->respondId(); ?>'),
holder = this.dom('comment-form-place-holder'),
input = this.dom('comment-parent');
if (null != input) {
input.parentNode.removeChild(input);
}
if (null == holder) {
return true;
}
this.dom('cancel-comment-reply-link').style.display = 'none';
holder.parentNode.insertBefore(response, holder);
return false;
}
};
})();
</script>
版权属于:泽泽社长
本文链接:https://blog.zezeshe.com/archives/instantclick-without-refresh-two.html
本站未注明转载的文章均为原创,并采用
CC BY-NC-SA 4.0 授权协议,转载请注明来源,谢谢!
都过去这么久了。。我还是没能弄明白如何“干掉模板自动输出的评论相关的js代码”。。。
在模板的
header.php
文件里有个会<?php $this->header('); ?>
改成<?php $this->header('commentReply='); ?>
即可干掉默认输出的评论js大佬大佬,请问评论功能弄好之后,每个文章的第一次评论css样式都会失效怎么解决
你这个播放器好酷,我打包放我我网站。
你这广告真是醉了、管家和360都直接给你报红了。。。。老铁 我看错你了 @(鄙视)
老铁,我很久不用360了,你不说我都不知道
你这广告拉的这么长很影响内容,泽泽喂 @(狂汗)
截图能否发给我看看,我这看着感觉还行啊
QQ云商城~ @(狂汗) @(狂汗) @(狂汗)
这种垃圾广告你也接?拉低博客质量... @(黑线)
我想接月宅这样的高质量广告但是没有人给我啊 @(滑稽)
关于instantclick进度条的美化 不知dalao有没有什么方案(就像友人C的那种 @(滑稽) )
有看到过,我这现在打不开哈,地址https://sa.bi/176.sb
@(呵呵) 哇,你接到广告了!!!
@(滑稽) 哇偶你接到广告了!
能赚点钱就是点哈
@(泪) @(黑线) 刚试了一下,我模板照着这样改一提交评论还是gg掉了,算了 @(笑尿)