我通过javascript成功更改了这些navmessage文本:

<div class='status-msg-body'
           <script
     var str=&#39;<data:navMessage/&#39;;

     str2=str.replace(&quot;Visualizzazione dei post in ordine di pertinenza per la query&quot;,&quot;Articoli
 contenenti:&quot;).replace(&quot;Visualizzazione post con
 etichetta&quot;,&quot;Articoli appartenenti alla
 categoria:&quot;).replace(&quot;Nessun post corrispondente alla
 query&quot;,&quot;Nessun articolo contiene&quot;);


     document.write(str2);
     </script
         </div

但是,如果我搜索带有撇号的词组,例如狗的,导航栏是空白的
有办法解决这个问题吗?
谢谢

最佳答案

不需要Javascript。修改此消息的更好方法是将每个<data:navMessage/>替换为:

<b:if cond='data:numPosts == 0'>
    <b:if cond='data:blog.searchLabel'>
        No posts for label: <b expr:data-search="data:blog.searchLabel"/>.
    <b:elseif cond='data:blog.searchQuery'/>
        No posts for query: <b expr:data-search="data:blog.searchQuery"/>.
    <b:elseif cond='data:blog.pageType == "error_page"'/>
        Page not found.
    <b:elseif cond='data:blog.url == data:blog.homepageUrl'/>
        No posts.
    </b:if>
<b:else/>
    <b:if cond='data:blog.searchLabel'>
        Posts for label: <b expr:data-search="data:blog.searchLabel"/>.
    <b:elseif cond='data:blog.searchQuery'/>
        Posts for query: <b expr:data-search="data:blog.searchQuery"/>.
    </b:if>
</b:if>
<data:blog.searchLabel/><data:blog.searchQuery/>是不安全的标签,因此最好通过CSS打印它们。

b[data-search]::after {
    content: attr(data-search);
}

关于blogger - Blogspot数据:navMessage,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21072954/

10-12 15:48