Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hide/Show text/image on load.

    I don't know if this can be done. I imagine it's pretty simple. I just don't know enough about Javascript to build it correctly.

    I have an Enjin.com site. They allow me to use HTML modules with Javascript enabled. What I am trying to do is display whether a Twitch.tv streamer is broadcasting(Live) or not. Twitch has APIs you can use to check.
    http://api.justin.tv/api/stream/list...annel=defatank
    If the channel is live, it will display something like:

    Code:
    [{"broadcast_part": 1, "featured": false, "channel_subscription": false,...etc.
    If they are not live it will simply display

    Code:
    []
    Javascript needs to check that API URL, determine whether the content is > or = "[]", then display or hide some text or image based on that. How can I do this?

    Thank you for your help.

  • #2
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Does anyone have any advise?

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    You can't do this with HTML and JavaScript, alone.

    JavaScript is not allowed to read content from any site except the one that created the HTML page.

    You would need a simple proxy server or similar. And that means you need some site that is capable of server-side coding: PHP or ASP or JSP, most likely.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •