请问如何在网页中嵌入一张外汇行情的表格?就像下面那个链接显示的那样。
http://forex.cnfol.com

解决方案 »

  1.   

    确实是需要实时交互
    用户的选择是AJAX
    而图表的自动更新是JS编写自动从服务器检测是否更新、取值再到更新
      

  2.   

    用js写一个方法实现刷新那一部分数据的功能,function func(){//...}
    然后在页面定时执行该方法setInterval("func()",5*60*1000);
      

  3.   

    protected void Page_Load(object sender, EventArgs e)
            {
                string url = "http://www.boc.cn/cn/common/whpj.html";
                string encodeType = "gb2312";
                string err = "";
                string postData2 = "";
             
                Response.Write(WebClinetPost(url, postData2, encodeType,out err));
            }        static string WebClinetPost(string url, string postData, string encodeType, out string err)
            {
                string uriString = url;
                byte[] byteArray;
                byte[] responseArray;            
                Encoding encoding = Encoding.GetEncoding(encodeType);
                try
                {
                    WebClient myWebClient = new WebClient();
                    WebHeaderCollection myWebHeaderCollection;
                    myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");                
                    myWebHeaderCollection = myWebClient.Headers;
                        
                    byteArray = encoding.GetBytes(postData);
                    responseArray = myWebClient.UploadData(uriString, "POST", byteArray);
                    err = string.Empty;
                    return encoding.GetString(responseArray);
                }
                catch (Exception ex)
                {
                    err = ex.Message;
                    return err;
                }
            }
      

  4.   

    1. ajax 异步获取那个页面中包含你要的内容的dom.html2. httprequest将指定页面加载到本地,做分析获取你 要的内容。
      

  5.   

    <iframe width="220" height="250" frameborder="0" scrolling="no" src="http://shell.cnfol.com/forex/Currency.php"></iframe>是一个 iframe 直接放入一个div 就可以了
      

  6.   

    楼主指的可是左上角的外汇行情的图表!建议,还是直接用第三方接口,估计要花点Money! 因为,就算你可以用ajax 实现这样的功能,但是,里面的实时数据 从何而来呢!?还是需要别人提供的哦!
      

  7.   

    最简单的方式就是IFRAME个外汇行情网站的图表页面。一些这类网站专门提供这种供引用的页面,去找一下就有了。
      

  8.   

    也是iframe<iframe scrolling="no" height="320" frameborder="0" width="220," id="frame" style="margin: 0pt; padding: 0pt;" src="http://trade.huidafx.com/for_price/chart_partners.html?style={&quot;title&quot;:{&quot;text&quot;:&quot;\u6b27\u5143\/\u7f8e\u5143%205\u5206\u949f&quot;,&quot;period&quot;:&quot;5&quot;,&quot;color&quot;:&quot;0x004A7C&quot;,&quot;size&quot;:&quot;12&quot;,&quot;font&quot;:&quot;\u5b8b\u4f53&quot;},&quot;tooltip&quot;:{&quot;backcolor&quot;:&quot;0xFFFFFF&quot;,&quot;color&quot;:&quot;0x004A7C&quot;,&quot;font&quot;:&quot;\u5b8b\u4f53&quot;,&quot;size&quot;:&quot;14&quot;,&quot;mod&quot;:&quot;1&quot;,&quot;timemod&quot;:&quot;m\/d%20h:i&quot;},&quot;background&quot;:{&quot;color&quot;:&quot;0xffffff&quot;},&quot;x_axis&quot;:{&quot;count&quot;:&quot;30&quot;,&quot;step&quot;:&quot;60&quot;,&quot;color&quot;:&quot;0x004A7C&quot;,&quot;size&quot;:&quot;9&quot;,&quot;font&quot;:&quot;Arial&quot;,&quot;timemod&quot;:&quot;h:i&quot;},&quot;y_axis&quot;:{&quot;count&quot;:&quot;3&quot;,&quot;color_a&quot;:&quot;0xf73b3b&quot;,&quot;color_b&quot;:&quot;0x1b8a03&quot;},&quot;y_list&quot;:{&quot;backcolor&quot;:&quot;0xff0000&quot;,&quot;color&quot;:&quot;0xffffff&quot;,&quot;size&quot;:&quot;9&quot;,&quot;font&quot;:&quot;Arial&quot;,&quot;timemod&quot;:&quot;h:i&quot;}}&amp;curr=EURUSD&amp;period=5&amp;width=220&amp;height=320&amp;data_c=30"></iframe>
      

  9.   

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="text8.aspx.vb" Inherits="New_text" Theme="SkinFile" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <!--[31,333,505] published at 2010-01-14 18:35:41 from #153 by 3473-->
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head>
    <title>人民币牌价_新浪财经_新浪网</title>
    <meta http-equiv="Content-type" content="text/html; charset=gb2312" />
    <style type="text/css">
    body {font-size:12px; margin:0px; padding:0px; padding-top:5px;}
    </style>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    </head>
    <body><!-- SUDA_CODE_START --> 
    <!-- 新浪财经首页导航 end --> <style type="text/css">
    .title_bar {background:url(http://i1.sinaimg.cn/cj/financewidget/image/lookup_bg.gif) repeat-x 0px -109px; border:1px solid #aaacbc; height:24px; margin:10px auto 0px auto; position:relative; width:948px;}
    .title_bar div {background-color:#fff; border-right:1px solid #aaacbc; height:25px; overflow:hidden; position:absolute; width:99px;}
    .title_bar label {background:url(http://i1.sinaimg.cn/cj/financewidget/image/lookup_bg.gif) repeat-x 0px -88px; border:1px solid #fff; color:#4c4c4c; display:block; font-size:14px; font-weight:bold; height:22px; line-height:22px; overflow:hidden; text-align:center; width:97px;} .body_container {border:1px solid #aaacbc; border-top:none; margin:0px auto; padding:9px; position:relative; width:930px;}
    .body_container table {border-collapse:collapse; width:930px;}
    .body_container table td, .body_container table th {border:1px solid #efefef; font-size:12px;  height:24px; line-height:24px; padding:0px; font-weight:normal;}
    .body_container table td {text-align:right; padding-right:10px;}
    .body_container table th {text-align:left; padding-left:10px;}
    .body_container table thead td, .body_container table thead th {background-color:#eee; color:#444; }
    </style>
    <div class="title_bar"><div style="left:0px;;"><label>人民币牌价</label></div></div>
    <div class="body_container" id="body_container">
    <table>
    <thead>
    <tr>
    <th>货币名称</th>
    <td>现汇买入价</td>
    <td>现钞买入价</td>
    <td>卖出价</td>
    <td>基准价</td>
    <td>中行折算价</td>
    <th>发布日期</th>
    <th>发布时间</th>
    </tr>
    </thead>
    <tbody>
    <!-- @LOOP@ -->
    <tr>
    <th><!-- @0@ --></th>
    <td><!-- @1@ --></td>
    <td><!-- @2@ --></td>
    <td><!-- @3@ --></td>
    <td><!-- @4@ --></td>
    <td><!-- @5@ --></td>
    <th><!-- @6@ --></th>
    <th><!-- @7@ --></th>
    </tr>
    <!-- @LOOP@ -->
    </tbody>
    </table>
    </div>
    <div style="color:#aaa; line-height:20px; margin:0px auto; padding:20px; width:910px;">
    <span style="font-weight:bold;">声明:</span>此数据系转载自中国银行网站,登载此数据出于传递更多信息之目的。此汇率表仅供参考,以中国银行各分行实际交易汇率为准,不构成投资建议。投资者据此买卖,风险自担。
    </div>
    <div id="script_loader" style="display:none;"></div>
    <script type="text/javascript">
        (new function () {
            this._get = function (__stringId) {
                return document.getElementById(__stringId);
            };
            this._random = function () {
                return (new Date()).getTime();
            };
            this._bind = function (__functionBind, __argumentsBind) {
                var __this = this;
                return function () {
                    var __arguments = null;
                    if (typeof __argumentsBind != "undefined") {
                        for (var i = 0; i < arguments.length; i++) {
                            __argumentsBind.push(arguments[i]);
                        }
                        __arguments = __argumentsBind;
                    }
                    else {
                        __arguments = arguments;
                    }
                    return __functionBind.apply(__this, __arguments);
                };
            };
            this._loadScript = function (__objectLoader, __stringUrl, __functionCallback) {
                var __elementScript = document.createElement("script");
                __elementScript.type = "text/javascript";
                __elementScript._functionCallback = typeof __functionCallback != "undefined" ? __functionCallback : new Function();
                __elementScript[document.all ? "onreadystatechange" : "onload"] = function () {
                    if (document.all && this.readyState != "loaded" && this.readyState != "complete") { return; }
                    this._functionCallback(this);
                    this._functionCallback = null;
                    this[document.all ? "onreadystatechange" : "onload"] = null;
                    this.parentNode.removeChild(this);
                };
                __elementScript.src = __stringUrl;
                (typeof __objectLoader == "string" ? document.getElementById(__objectLoader) : __objectLoader).appendChild(__elementScript);
            };
            this._arrayList = ["RMBGBP", "RMBHKD", "RMBUSD", "RMBCHF", "RMBSGD", "RMBSEK", "RMBDKK", "RMBNOK", "RMBJPY", "RMBCAD", "RMBAUD", "RMBEUR", "RMBMOP", "RMBPHP", "RMBTHB", "RMBNZD", "RMBKRW"];
            this._process = function (__stringCode) {
                var __stringHqCode = "hq_str_" + __stringCode;
                if (__stringHqCode in window) {
                    var __arrayData = window[__stringHqCode].split(",");
                    return __arrayData;
                }
            };
            this._fill = function () {
                var __stringHtmlTemplate = this._stringHtmlTemplate;
                var __arrayHtml = __stringHtmlTemplate.split("<!-- @LOOP@ -->");
                var __stringHtmlHead = __arrayHtml[0];
                var __stringHtmlBody = __arrayHtml[1];
                var __stringHtmlFoot = __arrayHtml[2];
                for (var i = 0; i < this._arrayList.length; i++) {
                    var __stringHtmlLoop = __stringHtmlBody;
                    var __arrayData = this._process(this._arrayList[i]);
                    var __arrayKeys = __stringHtmlLoop.match(/(<!--\s)?@[^@]*@(\s-->)?/gm);
                    if (__arrayKeys != null) {
                        for (var j = 0; j < __arrayKeys.length; j++) {
                            var __stringValue = __arrayData[__arrayKeys[j].replace(/(<!--\s)|(\s-->)/g, "").replace(/@/g, "")];
                            __stringValue = typeof __stringValue == "undefined" ? "--" : __stringValue;
                            __stringHtmlLoop = __stringHtmlLoop.replace(__arrayKeys[j], __stringValue);
                        }
                    }
                    __stringHtmlHead += __stringHtmlLoop.replace(/_style=/g, "style=");
                }
                this._elementTarget.innerHTML = __stringHtmlHead + __stringHtmlFoot;
            };
            this._load = function () {
                this._loadScript("script_loader", "http://hq.sinajs.cn/rn=" + this._random() + "&list=" + this._arrayList.join(","), this._bind(this._fill))
            };
            this.boot = function (__stringTargetId) {
                this._elementTarget = this._get(__stringTargetId);
                this._stringHtmlTemplate = this._elementTarget.innerHTML;
                this._load();
                setInterval(this._bind(this._load), 5 * 60 * 1000);
            };
        }).boot("body_container");
    </script><!-- END Nielsen//NetRatings SiteCensus V5.3 -->
    </body>
    </html>