Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌博客的编号页面导航不在搜索结果页面上工作_Javascript_Html_Css_Blogger - Fatal编程技术网

Javascript 谷歌博客的编号页面导航不在搜索结果页面上工作

Javascript 谷歌博客的编号页面导航不在搜索结果页面上工作,javascript,html,css,blogger,Javascript,Html,Css,Blogger,我在我的博客上添加了一个带编号的页面导航脚本,除了搜索结果页面(我搜索帖子时显示结果的页面)之外,它可以很好地处理所有页面——在该页面上显示默认的“以前的帖子和更新的帖子” 实际上,我对JavaScript了解不多,因此我需要帮助修改给定的JavaScript,使其在搜索结果页面上也能像Wordpress一样工作 我很乐意提供所需的任何其他详细信息 提前感谢…:-) /**/ /*lastPageNo)pageEnd=lastPageNo; html+=“+lastPageNo+”中的“页面”

我在我的博客上添加了一个带编号的页面导航脚本,除了搜索结果页面(我搜索帖子时显示结果的页面)之外,它可以很好地处理所有页面——在该页面上显示默认的“以前的帖子和更新的帖子”

实际上,我对JavaScript了解不多,因此我需要帮助修改给定的JavaScript,使其在搜索结果页面上也能像Wordpress一样工作

我很乐意提供所需的任何其他详细信息

提前感谢…:-)

/**/
/*lastPageNo)pageEnd=lastPageNo;
html+=“+lastPageNo+”中的“页面”+currentPageNo+”;
var prevNumber=parseInt(currentPageNo)-1;
//Iccsi在这里表演魔术
如果(当前页面号>1){
如果(当前页面==“页面”){
html+=''
}否则{
html+=''
}
}
如果(当前页面号>2){
如果(currentPageNo==3){
如果(当前页面==“页面”){
html+=''
}否则{
html+=''
}
}否则{
如果(当前页面==“页面”){
html+=''
}否则{
html+=''
}
}
}
如果(页面开始>1){
如果(当前页面==“页面”){
html+=''
}否则{
html+=''
}
}
如果(页面开始>2){
html+=“…”
}
对于(var jj=pageStart;jj 0){
html=“”
}
如果(博客寻呼机){
blogPager.innerHTML=html
}
}
函数totalcountdata(根){
var feed=root.feed;
var totaldata=parseInt(feed.openSearch$totalResults.$t,10);
looppagecurrentg(总数据)
}
函数pagecurrentg(){
var thisUrl=urlactivepage;
if(thisUrl.indexOf(“/search/label/”)=-1){
如果(thisUrl.indexOf(“?更新的最大值”)!=-1){
postLabel=thisUrl.substring(thisUrl.indexOf(“/search/label/”)+14,thisUrl.indexOf(“?updated max”))
}否则{
postLabel=thisUrl.substring(thisUrl.indexOf(“/search/label/”)+14,thisUrl.indexOf(“?&max”))
}
}
if(thisUrl.indexOf(“?q=”)=-1&&thisUrl.indexOf(“.html”)=-1){
if(thisUrl.indexOf(“/search/label/”)==-1){
currentPage=“page”;
if(urlactivepage.indexOf(“#PageNo=”)!=-1){
currentPageNo=urlactivepage.substring(urlactivepage.indexOf(“#PageNo=”)+8,urlactivepage.length)
}否则{
currentPageNo=1
}
文件。写(“”)
}否则{
currentPage=“标签”;
if(thisUrl.indexOf(“&max results=”)=-1){
每页=20
}
if(urlactivepage.indexOf(“#PageNo=”)!=-1){
currentPageNo=urlactivepage.substring(urlactivepage.indexOf(“#PageNo=”)+8,urlactivepage.length)
}否则{
currentPageNo=1
}
文件。写入(“”)
}
}
}
功能重定向页(数字页){
jsonstart=(数字页-1)*每页;
noPage=numberpage;
var nameBody=document.getElementsByTagName('head')[0];
var newInclude=document.createElement('script');
newInclude.type='text/javascript';
newInclude.setAttribute(“src”,主页+”提要/帖子/摘要?开始索引=“+jsonstart+”&脚本中的max results=1&alt=json&callback=finddatepost”);
nameBody.appendChild(newInclude)
}
函数重定向标签(numberpage){
jsonstart=(数字页-1)*每页;
noPage=numberpage;
var nameBody=document.getElementsByTagName('head')[0];
var newInclude=document.createElement('script');
newInclude.type='text/javascript';
newInclude.setAttribute(“src”,主页+”提要/帖子/摘要/-/“+postLabel+”?开始索引=“+jsonstart+”&脚本中的max results=1&alt=json&callback=finddatepost”);
nameBody.appendChild(newInclude)
}
函数findDataPost(根){
post=root.feed.entry[0];
var timestamp1=发布后的$t.substring(0,19)+发布后的$t.substring(23,29);
var timestamp=encodeURIComponent(timestamp 1);
如果(当前页面==“页面”){
var pAddress=“/search?updated max=“+timestamp+”&max results=“+perPage+”#PageNo=“+noPage
}否则{
var pAddress=“/search/label/”+postlab+”?更新的max=“+timestamp+”&max results=“+perPage+”#PageNo=“+noPage
}
location.href=pAddress
}
/*]]>*/
#博客寻呼机{清除:两者;边距:30px自动;文本对齐:居中;填充:7px;}
.blog页面{背景:无;}
.displaypageNum a、.showpage a、.pagecurrent{字体大小:13px;填充:5px 12px;右边距:5px;颜色:#AD0B00;背景色:#FAB001;}
.displaypageNum a:hover、.showPageA:hover、.pagecurrent{background:#DB4920;文本装饰:无;颜色:#fff;}
#blog pager.pagecurrent{font-weight:bold;color:#fff;background:#DB4920;}
.showpageOf{display:none!important}

#blog pager.pages{border:none;}
首先,您必须修改搜索框,将表单操作属性从

action="/search/max-results=12"

max results
参数指定为隐藏的
输入
字段

<input type='hidden' name='max-results' value="12" />
并将其替换为-

if (thisUrl.indexOf(".html") == -1)
function pagecurrentg() {
    var thisUrl = urlactivepage;
    if (thisUrl.indexOf("/search/label/") != -1) {
        if (thisUrl.indexOf("?updated-max") != -1) {
            postLabel = thisUrl.substring(thisUrl.indexOf("/search/label/") + 14, thisUrl.indexOf("?updated-max"))
        } else {
            postLabel = thisUrl.substring(thisUrl.indexOf("/search/label/") + 14, thisUrl.indexOf("?&max"))
        }
    }
    if (thisUrl.indexOf(".html") == -1) {
        if (thisUrl.indexOf("/search/label/") == -1) {
            currentPage = "page";
            if (urlactivepage.indexOf("#PageNo=") != -1) {
                currentPageNo = urlactivepage.substring(urlactivepage.indexOf("#PageNo=") + 8, urlactivepage.length)
            } else {
                currentPageNo = 1
            }
            if(thisUrl.indexOf("q=") == -1){
                document.write("<script src=\"" + home_page + "feeds/posts/summary?max-results=1&alt=json-in-script&callback=totalcountdata\"><\/script>")
            } else {
                document.write("<script src=\"" + home_page + "feeds/posts/summary?q=" + thisUrl.split("?")[1].split("q=")[1].split("&")[0] + "&alt=json-in-script&callback=totalcountdata\"><\/script>")
            }
       } else {
            currentPage = "label";
            if (thisUrl.indexOf("&max-results=") == -1) {
                perPage = 20
            }
            if (urlactivepage.indexOf("#PageNo=") != -1) {
                currentPageNo = urlactivepage.substring(urlactivepage.indexOf("#PageNo=") + 8, urlactivepage.length)
            } else {
                currentPageNo = 1
            }
            document.write('<script src="' + home_page + 'feeds/posts/summary/-/' + postLabel + '?alt=json-in-script&callback=totalcountdata&max-results=1" ><\/script>')
        }
    }
}
function finddatepost(root) {
    post = root.feed.entry[0];
    var timestamp1 = post.published.$t.substring(0, 19) + post.published.$t.substring(23, 29);
    var timestamp = encodeURIComponent(timestamp1);
    if (currentPage == "page") {
        if(urlactivepage.indexOf("?q=") == -1){
                var pAddress = "/search?updated-max=" + timestamp + "&max-results=" + perPage + "#PageNo=" + noPage
        } else {
                var pAddress = "/search?updated-max=" + timestamp + "&q="+ urlactivepage.split("?")[1].split("q=")[1].split("&")[0] +"&max-results=" + perPage + "#PageNo=" + noPage
            }
        } else {
        var pAddress = "/search/label/" + postLabel + "?updated-max=" + timestamp + "&max-results=" + perPage + "#PageNo=" + noPage
    }
    location.href = pAddress
}
上述条件(aka
thisUrl.indexOf(“?q=”)==-1
)正在停止脚本在URL中具有名为
q
的查询参数的页面上工作

编辑1:用于在搜索结果页面上显示正确的页码 在上述代码中搜索以下函数-

function redirectpage(numberpage) {
    jsonstart = (numberpage - 1) * perPage;
    noPage = numberpage;
    var nameBody = document.getElementsByTagName('head')[0];
    var newInclude = document.createElement('script');
    newInclude.type = 'text/javascript';
    newInclude.setAttribute("src", home_page + "feeds/posts/summary?start-index=" + jsonstart + "&max-results=1&alt=json-in-script&callback=finddatepost");
    nameBody.appendChild(newInclude)
}
function redirectpage(numberpage) {
    jsonstart = (numberpage - 1) * perPage;
    noPage = numberpage;
    var nameBody = document.getElementsByTagName('head')[0];
    var newInclude = document.createElement('script');
    newInclude.type = 'text/javascript';
    if(urlactivepage.indexOf("?q=") == -1){
        newInclude.setAttribute("src", home_page + "feeds/posts/summary?start-index=" + jsonstart + "&max-results=1&alt=json-in-script&callback=finddatepost");
    } else {
        newInclude.setAttribute("src", home_page + "feeds/posts/summary?start-index=" + jsonstart + "&alt=json-in-script&q="+ urlactivepage.split("?")[1].split("q=")[1].split("&")[0] +"&callback=finddatepost");  
    }
    nameBody.appendChild(newInclude);
}
function pagecurrentg() {
    var thisUrl = urlactivepage;
    if (thisUrl.indexOf("/search/label/") != -1) {
        if (thisUrl.indexOf("?updated-max") != -1) {
            postLabel = thisUrl.substring(thisUrl.indexOf("/search/label/") + 14, thisUrl.indexOf("?updated-max"))
        } else {
            postLabel = thisUrl.substring(thisUrl.indexOf("/search/label/") + 14, thisUrl.indexOf("?&max"))
        }
    }
    if (thisUrl.indexOf("?q=") == -1 && thisUrl.indexOf(".html") == -1) {
        if (thisUrl.indexOf("/search/label/") == -1) {
            currentPage = "page";
            if (urlactivepage.indexOf("#PageNo=") != -1) {
                currentPageNo = urlactivepage.substring(urlactivepage.indexOf("#PageNo=") + 8, urlactivepage.length)
            } else {
                currentPageNo = 1
            }
            document.write("<script src=\"" + home_page + "feeds/posts/summary?max-results=1&alt=json-in-script&callback=totalcountdata\"><\/script>")
        } else {
            currentPage = "label";
            if (thisUrl.indexOf("&max-results=") == -1) {
                perPage = 20
            }
            if (urlactivepage.indexOf("#PageNo=") != -1) {
                currentPageNo = urlactivepage.substring(urlactivepage.indexOf("#PageNo=") + 8, urlactivepage.length)
            } else {
                currentPageNo = 1
            }
            document.write('<script src="' + home_page + 'feeds/posts/summary/-/' + postLabel + '?alt=json-in-script&callback=totalcountdata&max-results=1" ><\/script>')
        }
    }
}
function pagecurrentg() {
    var thisUrl = urlactivepage;
    if (thisUrl.indexOf("/search/label/") != -1) {
        if (thisUrl.indexOf("?updated-max") != -1) {
            postLabel = thisUrl.substring(thisUrl.indexOf("/search/label/") + 14, thisUrl.indexOf("?updated-max"))
        } else {
            postLabel = thisUrl.substring(thisUrl.indexOf("/search/label/") + 14, thisUrl.indexOf("?&max"))
        }
    }
    if (thisUrl.indexOf(".html") == -1) {
        if (thisUrl.indexOf("/search/label/") == -1) {
            currentPage = "page";
            if (urlactivepage.indexOf("#PageNo=") != -1) {
                currentPageNo = urlactivepage.substring(urlactivepage.indexOf("#PageNo=") + 8, urlactivepage.length)
            } else {
                currentPageNo = 1
            }
            if(thisUrl.indexOf("q=") == -1){
                document.write("<script src=\"" + home_page + "feeds/posts/summary?max-results=1&alt=json-in-script&callback=totalcountdata\"><\/script>")
            } else {
                document.write("<script src=\"" + home_page + "feeds/posts/summary?q=" + thisUrl.split("?")[1].split("q=")[1].split("&")[0] + "&alt=json-in-script&callback=totalcountdata\"><\/script>")
            }
       } else {
            currentPage = "label";
            if (thisUrl.indexOf("&max-results=") == -1) {
                perPage = 20
            }
            if (urlactivepage.indexOf("#PageNo=") != -1) {
                currentPageNo = urlactivepage.substring(urlactivepage.indexOf("#PageNo=") + 8, urlactivepage.length)
            } else {
                currentPageNo = 1
            }
            document.write('<script src="' + home_page + 'feeds/posts/summary/-/' + postLabel + '?alt=json-in-script&callback=totalcountdata&max-results=1" ><\/script>')
        }
    }
}
function finddatepost(root) {
    post = root.feed.entry[0];
    var timestamp1 = post.published.$t.substring(0, 19) + post.published.$t.substring(23, 29);
    var timestamp = encodeURIComponent(timestamp1);
    if (currentPage == "page") {
        var pAddress = "/search?updated-max=" + timestamp + "&max-results=" + perPage + "#PageNo=" + noPage
    } else {
        var pAddress = "/search/label/" + postLabel + "?updated-max=" + timestamp + "&max-results=" + perPage + "#PageNo=" + noPage
    }
    location.href = pAddress
}
function finddatepost(root) {
    post = root.feed.entry[0];
    var timestamp1 = post.published.$t.substring(0, 19) + post.published.$t.substring(23, 29);
    var timestamp = encodeURIComponent(timestamp1);
    if (currentPage == "page") {
        if(urlactivepage.indexOf("?q=") == -1){
                var pAddress = "/search?updated-max=" + timestamp + "&max-results=" + perPage + "#PageNo=" + noPage
        } else {
                var pAddress = "/search?updated-max=" + timestamp + "&q="+ urlactivepage.split("?")[1].split("q=")[1].split("&")[0] +"&max-results=" + perPage + "#PageNo=" + noPage
            }
        } else {
        var pAddress = "/search/label/" + postLabel + "?updated-max=" + timestamp + "&max-results=" + perPage + "#PageNo=" + noPage
    }
    location.href = pAddress
}