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