1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Having issues trying to use a jquery script to redirect my tumblr homepage

Discussion in 'JavaScript' started by blogdog, Oct 4, 2012.

  1. #1
    I'm using the code below to redirect my Tumblr homepage to my latest post.

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
    <script>
    $(document).ready(function() {
    $.getJSON('http://mydomain.tumblr.com/api/read/json?callback=?', function(result) {
    window.location.href = result.posts[0].url;
    });
    });
    </script>

    I'm having two problems with it. First, it doesn't redirect instantly, it loads my homepage and then changes the URL, even though I've placed it above my <head> tag. Then when it does redirect it starts refreshing every few seconds. Thanks in advance for any help.
     
    blogdog, Oct 4, 2012 IP
  2. funty

    funty Greenhorn

    Messages:
    12
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    18
    #2
    try meta tag or maybe header function from PHP

    Meta tag
    
    http://www.w3schools.com/tags/tag_meta.asp
    
    Code (markup):
     
    funty, Oct 6, 2012 IP