显示div只在tumblr博客主页? [英] displaying a div only on tumblr blog homepage?

查看:165
本文介绍了显示div只在tumblr博客主页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当初步的理解CSS和HTML,我想尝试做一些我认为应该相对简单(在我创建的自定义tumblr主题),但我找不到一个直截了当的答案。我有一个感觉,可能是一个超级简单的方法来做我想要的JavaScript。

I have a fairly novice understanding of CSS and HTML, and I'm trying to do something that I think should be relatively simple (in a custom tumblr theme I'm creating), but I can't find a straightforward answer. I have a feeling there might be a super easy way to do what I want in JavaScript.

我想显示一个 DIV 仅在tumblr博客的主索引页(即主页)上。看起来文档tumblr提供允许你在某种程度上(通过{Block:IndexPage}变量),但问题是这个元素中的代码显示在所有索引页面上(即,而不是只显示在/ page / 1的根级别,它会显示在后续的index页面,如/ page / 2等。

I'd like to display a DIV only on the main index page (i.e. homepage) of the tumblr blog. It seems the documentation tumblr provides allows you to do this to some extent (through the {Block:IndexPage} variable), but the problem is the code within this element displays on all index pages (i.e. instead of just showing up at the root level on /page/1, it will show up on subsequent "index" pages like /page/2, etc.

已成功地在永久链接页面上不显示div:

Here's the code I have, which successfully does not show the div on permalink pages:

{block:IndexPage}
    <div class="mid2">
        <div class="midLeft2">  
            <p>test</p>
        </div>   
    </div>
{/block:IndexPage}  

任何想法? / p>

Any ideas? Any help is much appreciated!

推荐答案

我结束了彻底清除{Block:IndexPage}标签,并将原始div标注更改为:

I ended up killing off the {Block:IndexPage} tag altogether and changing the original div callout to this:

<div id="splashbox" class="mid2" style="display:none">

后跟此脚本:

<script type="text/javascript">
window.onload=showsplashbox();
function showsplashbox() {
   //alert('location identified as ' + location.href);
   if (location.href == 'http://site.tumblr.com/' || location.href == 'http://site.tumblr.com') {
           //alert('location match, show the block');
           document.getElementById('splashbox').style.display='block';
   }
}
</script>

这篇关于显示div只在tumblr博客主页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆