1. 效果图:
2. 使用方法:根据文件名获取股票代码:sh代表上海 沪股,sz代表深圳 深股 ,例如:sh600571
3. 代码:
<html> <head> <meta http-equiv="refresh" content="3"> <title>Sina JS</title> <script type="text/javascript"> var path = window.location.pathname; var paths = path.split("/"); var filenameWithExt = paths[paths.length-1]; var filenameWithExts = filenameWithExt.split("."); var filenameNoExt = filenameWithExts[0]; var number = filenameNoExt; var src="http://hq.sinajs.cn/list=" + number; document.write('<scr'+'ipt src="'+src+ '"></scr'+'ipt>'); document.title = number.toUpperCase(); </script> <script type="text/javascript"> var param_string = "hq_str_" + number; var param = eval(param_string); var elements = param.split(","); var Yesterday = elements[2]; var Current = elements[3]; var range = (Current/Yesterday - 1) * 100; range = range.toFixed(2); document.write("<br />Name:"+elements[0]); document.write("<br />Today:"+elements[1]); document.write("<br />Yesterday:"+elements[2]); document.write("<br />High:"+elements[4]); document.write("<br />Low:"+elements[5]); document.write("<br />"); if(range > 0){ document.write("<br /><font color='red'>Current:" + elements[3] + "</font>"); }else{ document.write("<br /><font color='green'>Current:" + elements[3] + "</font>"); } document.write("<br />"); if(range > 0){ document.write("<br /><font color='red'>Range:" + range + "%</font>"); }else{ document.write("<br /><font color='green'>Range:" + range + "%</font>"); } </script> </head> <body><body> </html>
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-11-06 07:34:05