个人Tumblr帖子上的Javascript [英] Javascript on Individual Tumblr Post

查看:111
本文介绍了个人Tumblr帖子上的Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以编辑在tumblr博客上呈现所有帖子博客主页的html / AngularJS。但是,有没有办法在个别帖子中添加自定义< script> ...< / script> ?我想在逐个帖子的基础上做一些javascript的东西,似乎无法找到代码可以编辑的地方(或者,如果它甚至可以)......

I am aware that you can edit the html/AngularJS that renders the all posts blog homepage on a tumblr blog. But, is there any way to add a custom <script>...</script> to the individual posts? I want to do some javascript stuff on a post-by-post basis, and cant seem to find where that code can be edited (or, if it even can)...

推荐答案

撰写帖子时,在菜单栏上可以点击粗体,斜体,删除线等,有一个按钮,显示< html> 。如果单击此按钮,将显示该帖子的HTML。然后,您所要做的就是添加一个脚本标记,其中包含您想要的javascript代码。例如:

When writing a post, on the menu bar where you can click bold, italic, strikethrough, etc, there is a button that says <html>. If you click this, it will bring up the HTML for the post. Then, all you do is have to add a script tag with the javascript code you want. For example:

<script>
    alert("Hello World!");
</script>

注意:我相信javascript仅在用户导航到您的实际页面,而不是在它们的Feed中,除非单击显示代表额外内容的框。这是为了防止显示不必要的内容并在Feed中保持较低的加载时间

NOTE: I believe the javascript will only work when users navigate to your actual page, not when it is in their feed unless the box that is shown to represent extra content is clicked. This is to prevent unnecessary content from showing and keeping load time low in the feed

编辑:如果您希望将相同的javascript应用于所有内容你写的帖子,我把它放到主题的HTML中。为此,您需要转到自定义 - >编辑HTML(主题) - > put< script>在身体的底部(一般来说)或添加到现有的< script> 。每个帖子都有 .POST 类,因此请使用该选择器获取每个帖子。要了解各种类型的类别,您可以查看 Tumblr API 或者使用inspect元素自行查找

EDIT: If you want the same javascript to apply to all posts you write, I'd put it into the theme's HTML. To do so you'd go to Customize -> Edit HTML (of the theme) -> put <script> at the bottom of body (generally speaking) or add to an existing <script>. Each posts has the class .POST, so use that selector to obtain each. To find out the classes of individual types you can look at the Tumblr API or use inspect element to find out for yourself

注意:添加到主题中的脚本不会影响用户Feed中的帖子。这是对主题的更改,因此不会直接在网站上看到个别帖子。

NOTE: The script added to the theme will not affect posts in user's feed. It is a change to the theme, thus will not affect individual posts when seen not directly on the site.

这篇关于个人Tumblr帖子上的Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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