PDA

View Full Version : Đưa thêm thông tin tỉ giá, giá vàng, nhiệt độ vào trang web.



matrix
15-05-07, 10:05 AM
Sáng nay có một bạn hỏi ḿnh việc này đầu bài như sau :
- Đưa vào trang web của ḿnh các thông tin bao gồm : Thông tin tỷ giá, giá vàng và nhiệt độ, các biểu đồ chứng khoán mà không phải mất công ngồi nhập dữ liệu cho cái đám đó :021:

Ḿnh tạm thời giải quyết như sau :
- Download 4 file js từ vnexpress về bao gồm :
+ http://www.vnexpress.net/Library/Library.js
+ http://vnexpress.net/Service/Gold.js
+ http://vnexpress.net/Service/Weather.js
+ http://vnexpress.net/Service/Forex.js
Ok, sau đó ḿnh có thể chỉnh sửa các file đó sao cho hiển thị theo cách ḿnh muốn.
Tiếp tục ḿnh chèn đoạn code sau vào trang web của ḿnh


<script language="JavaScript" src="Library.js"></script>
<script type="text/javascript" language="JavaScript" src="http://vnexpress.net/Service/Gold_Content.js"></Script>
<script type="text/javascript" language="JavaScript" src="Gold.js"></Script>

<script type="text/javascript" language="JavaScript" src="http://vnexpress.net/Service/Weather_Content.js"></Script>
<script type="text/javascript" language="JavaScript" src="Weather.js"></Script>


<script type="text/javascript" language="JavaScript" src="http://vnexpress.net/Service/Forex_Content.js"></Script>
<script type="text/javascript" language="JavaScript" src="Forex.js"></Script>


:02: Thế là xong, nhờ luôn dữ liệu hàng ngày của VNExpress để hiển thị trên trang web của ḿnh :71:

TuanMA
15-05-07, 02:40 PM
&#212;ng tướng xem chỉnh lại c&#225;i đi, xấu qu&#225;

matrix
15-05-07, 02:43 PM
H&#237;c, t&#244;i n&#243;i r&#245; l&#224;
"Ok, sau đ&#243; m&#236;nh c&#243; thể chỉnh sửa c&#225;c file đ&#243; sao cho hiển thị theo c&#225;ch m&#236;nh muốn."

Bố kh&#244;ng chỉnh cứ thế phang l&#234;n, c&#243; c&#225;i ảnh minimize bố cũng lười down về bảo sao n&#243; xấu. h&#237;c

matrix
15-05-07, 03:08 PM
Ḿnh tiếp tục giới thiệu cách lấy thông tin các giá các chỉ số chứng khoán nhé. Bác nào quan tâm th́ thanks nhé :014:

Bước 1 :
Vào địa chỉ http://www.vnexpress.net/Vietnam/Kinh-doanh/Chung-khoan/ sau đó save as trang web về (chú ư : save toàn bộ về máy với định dạng .htm), lưu với tên ChungKhoan.htm (Máy sẽ tạo ra 1 folder có tên là ChungKhoan chứa các ảnh cần thiết cho form này và file ChungKhoan.htm)

Bước 2 : Chạy thử file ChungKhoan.htm --> Nếu hiển thấy bảng giá chứng khoán hiển thị th́ tiếp tục, không thấy th́ cứ làm tiếp :E , kiểm tra kết nối Internet sau :014:

Bước 3 : Tạo một file hml mới có tên là CK.htm

Bước 4 : Tạo styles cho các thành phần hiển thị


<style type="text/css">
.cActive
{
background-image:url(/User/ck/Source/images/bg_active.gif);
font-family:Tahoma, "Times New Roman";
text-decoration:none;
font-size:11px;
color:#9e224d;
font-weight:bold;
}
.cNoActive
{
background-image:url(/User/ck/Source/images/bg_noactive.gif);
font-family:Tahoma, "Times New Roman";
text-decoration:none;
font-size:11px;
color:#009140;
font-weight:normal;
}
.tbHeader
{
border-left: 1px solid #666666;
border-right: 1px solid #666666;
}
.cHeader
{
font-family:Tahoma, "Times New Roman";
font-size:11px;
background-color:#9e224d;
color:#FFFFFF;
font-weight:bold
}
.cHeaderN
{
font-family:Tahoma, "Times New Roman";
font-size:11px;
background-color:#af637d;
color:#FFFFFF;
font-weight:bold
}
.Active
{
font-family:Tahoma, "Times New Roman";
text-decoration:none;
font-size:12px;
color:#9e224d;
font-weight:bold;
cursor: pointer;
}
.NoActive
{
font-family:Tahoma, "Times New Roman";
text-decoration:none;
font-size:12px;
color:#009140;
font-weight:normal;
cursor: pointer;
}
</style>


Bước 5 : Thêm đoạn code sau để hiển thị bảng giá, tận dụng dữ liệu được cung cấp từ CTy CK Vietcombank :105:




<script language="javascript">
function switchActive(i){
if(i == 0){
document.getElementById('cHoSTC').className = 'cActive';
document.getElementById('cHaSTC').className = 'cNoActive';
document.getElementById('aHoSTC').className = 'Active';
document.getElementById('aHaSTC').className = 'NoActive';
}
else{
document.getElementById('cHoSTC').className = 'cNoActive';
document.getElementById('cHaSTC').className = 'cActive';
document.getElementById('aHoSTC').className = 'NoActive';
document.getElementById('aHaSTC').className = 'Active';
}
}
</script>
<table border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td valign="top" width="210">
<table border="0" cellpadding="0" cellspacing="0" width="210">
<tbody><tr>
<td colspan="8" align="center" height="14" width="194"><img src="Chungkhoan_files/title.gif"></td>
</tr>
<tr>
<td colspan="7" align="justify" height="32" width="122"><img src="Chungkhoan_files/vnes_title.gif"></td>
<td rowspan="2" align="center" background="Chungkhoan_files/vcb_bg.gif" width="72"><img src="Chungkhoan_files/vcb_logo.gif"></td>
</tr>
<tr>
<td alt="" background="Chungkhoan_files/bd.gif" height="20" width="1"></td>
<td id="cHoSTC" class="cActive" alt="" align="center" height="20" width="58"><a href="http://www.vnexpress.net/User/ck/hcms/HCMStockSmall.asp" target="ifrmContent" id="aHoSTC" class="Active" onclick="switchActive(0);">HoSTC</a></td>
<td alt="" background="Chungkhoan_files/bd.gif" height="20" width="1"></td>
<td alt="" background="Chungkhoan_files/bg_out.gif" height="20" width="2"></td>
<td alt="" background="Chungkhoan_files/bd.gif" height="20" width="1"></td>
<td id="cHaSTC" class="cNoActive" alt="" align="center" height="20" width="58"><a href="http://www.vnexpress.net/User/ck/hns/HNStockSmall.asp" target="ifrmContent" id="aHaSTC" class="NoActive" onclick="switchActive(1);">HaSTC</a></td>
<td alt="" background="Chungkhoan_files/bd.gif" height="20" width="1"></td>
</tr>
</tbody></table>
<table class="tbHeader" border="0" cellpadding="1" cellspacing="1" width="210">
<tbody><tr align="center">
<td rowspan="2" class="cHeader" align="center" width="38">Mă CK</td>
<td rowspan="2" class="cHeader" align="center" width="38">TC</td>
<td colspan="2" class="cHeader" align="center" nowrap="nowrap" width="82">Khớp lệnh</td>
<td rowspan="2" class="cHeader" align="center" width="52">+/-</td>
</tr>
<tr>
<td class="cHeaderN" align="center" width="37">Giá</td>
<td class="cHeaderN" align="center" width="45">KL</td>
</tr>
</tbody></table>
<iframe id="ifrmContent" name="ifrmContent" height="305" width="210" src="http://www.vnexpress.net/User/ck/hcms/HCMStockSmall.asp" noresize border=false frameborder=0 scrolling="no"></iframe>
<table>
<tbody><tr>
<td style="background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 8pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: rgb(0, 0, 0); font-family: 'Arial'; text-align: right;" align="center">(Bấm vào nội dung bảng để xem chi tiết)</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table><table>

TuanMA
15-05-07, 03:45 PM
Kinh dị nhỉ? để xem c&#243; đưa l&#234;n được kh&#244;ng

rosekiller
15-05-07, 06:45 PM
th&#244;i th&#244;i &#244;ng ơi, kh&#244;ng cần thiết đ&#226;u. Đưa mấy c&#225;i tin hot hot về c&#244;ng nghệ th&#236; hay hơn.

matrix
15-05-07, 07:06 PM
:( &#218;i c&#225;c b&#225;c n&#224;y buồn cười nhỉ, c&#225;i n&#224;y em hướng dẫn người ta l&#224;m quen với việc ph&#225;t triển c&#225;c hệ thống web m&#224;.

Admin thấy d&#249;ng được c&#225;i n&#224;o th&#236; d&#249;ng m&#224; ... kh&#244;ng an ủi box web th&#236; th&#244;i lại c&#242;n... hic hic.. tủi th&#226;n v&#227;i

TuanMA
15-05-07, 07:06 PM
Hi hi hi, từ từ rồi khoai sẽ nhừ.

matrix
15-05-07, 07:34 PM
HI vọng c&#225;i form t&#236;m việc thỏa m&#227;n được sự bức x&#250;c của anh em :)

thangtam
08-06-07, 06:01 PM
c&#225;i đấy hay ra phết c&#243; t&#237;ch hợp v&#224;o powerpoint được kh&#244;ng ?