Web Analytics Made Easy -
StatCounter Embed Market Stock Bar - CodingForum


No announcement yet.

Embed Market Stock Bar

  • Filter
  • Time
  • Show
Clear All
new posts

  • Embed Market Stock Bar

    Hello all, I'm looking for a Market stock bar similar
    to http://www.bloomberg.com/

    I've been looking around and can't find any API's or examples.

    Could someone point me in the right direction?

  • #2
    I found this information on Stackoverflow:
    <script type="text/javascript" src="jquery-1.5.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
                var symbol='goog';
                var callback = function(data) {
                        var price=data.query.results.span[0].content;
                        alert('Stock Price: ' + price);
                var url = 'http://query.yahooapis.com/v1/public/yql';
                // this is the lovely YQL query (html encoded) which lets us get the stock price:
                // select * from html where url="http://finance.yahoo.com/q?s=goog" and xpath='//span[@id="yfs_l10_goog"]'
                var data = "q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Ffinance.yahoo.com%2Fq%3Fs%3D" + symbol + "%22%20and%20xpath%3D'%2F%2Fspan%5B%40id%3D%22yfs_l10_" + symbol + "%22%5D'&format=json";
                $.getJSON(url, data, callback);
    It uses jquery, but if you're not already using jquery you could modify this to work without it...
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting