English 中文(简体)
Display two independent Tumblr blogs on one page?
原标题:

I d like to display two independent Tumblr blogs next to each other on one page. I d like them to look identical to their Tumblr theme. What s the best way to do this?

I m able to use JavaScript to import the content like this:

<div id="tumblr1">
  <script type="text/javascript" src="http://tumblr1.tumblr.com/js"></script>
<div>

<div id="tumblr2">
  <script type="text/javascript" src="http://tumblr2.tumblr.com/js"></script>
<div>

But the content obviously won t be styled. Is there a simpler way to do this? If not, is there a simple way to style the content I m getting from the js?

UPDATE:
I m working on parsing the JSON but JavaScript not liking the dashes in the property values. For a simplified example:

<script type="text/javascript">
    var tumblelog = {

                    "title":"Tumblr Title",
                    "description":"Tumblr Description",
                    "name":"tumblr name",
                    "timezone":"US/Central",
                    "cname":false,
                    "feeds":0,
                    "posts-start":0,
                    "posts-total":"111",
                    "posts-type":false

                    };

</script>

<script type="text/javascript">

     document.write(tumblelog.posts-total);

</script>

tells me "Uncaught ReferenceError: total is not defined". However,

<script type="text/javascript">

     document.write(tumblelog.feeds);

</script>

returns 0 just fine. Tumblr s API suggests something like

     document.write(tumblelog[ @posts-total ]);

when working with but that returns "undefined".

Any suggestions?

问题回答

I d like them to look identical to their Tumblr theme.

Use iFrames?

I d use the api and set a json callback

<script type="text/javascript"
src="http://tumblr1.tumblr.com/api/read/json?callback=my_callback"></script>

<script type="text/javascript"
src="http://tumblr2.tumblr.com/api/read/json?callback=my_callback"></script>

Then just have a callback ready:

function my_callback(tumblr_data)
{
    //append the data to the div here
}

You can find the tumblr api read docs here.

EDIT: Or you could do it this way, without a callback:

<div id="tumblr1">
    <script type="text/javascript" src="http://tumblr1.tumblr.com/api/read/json"></script>
    <script type="text/javscript">
        parse_tumblr_data(tumblr_api_read);
    </script>
<div>

<div id="tumblr2">
    <script type="text/javascript" src="http://tumblr2.tumblr.com/api/read/json"></script>
    <script type="text/javscript">
        parse_tumblr_data(tumblr_api_read);
    </script>
<div>

I ve used the above example before on this site to change the color on Tumblr s audio player... but you can do whatever you want.

tumblelog[ @posts-total ] will look for for the @posts-total key of the tumblelog obj, which doesn t exists.

Do this:

document.write(tumblelog[ posts-total ]);




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签