Re: [問題] [js] 內嵌別的網站圖片

看板Ajax作者 (愁痕飄絮)時間15年前 (2009/05/08 01:28), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/3 (看更多)
※ 引述《kevintwo (MAI舞)》之銘言: : 本來想說內嵌氣象局網頁裡的衛星雲圖到網頁裡 : 於是去了中央氣象局的網頁查看,但發現它是用圖片表示的 : 利用javascript 產生動態感 : :http://www.cwb.gov.tw/V6/js/LoopSat3.js (裡面的ShowOneOrMore()) ----(1) : 而想問的問題是,要怎麼做到內嵌呢? : 我看它的js內容是動態在改變的 : 如:http://www.cwb.gov.tw/V6/js/s1p_val.js -----(2) : 直接link 好像不行的樣子,因為js寫的圖檔位置是相對路徑? : 麻煩各位大大給予提示指點了 謝謝~ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PTT</title> <style type="text/css"> #satellite_image_container {background-color:#eee; border:1px solid #aaa; padding:15px; width:400px; height:430px;} </style> </head> <body> <div id="satellite_image_container"> <img class="rotator" /> </div> <script type="text/javascript" src="" rel="nofollow">http://www.cwb.gov.tw/V6/js/s1p_val.js"> </script> <script type="text/javascript" > var Rotator = function() { var data = window.s1p_val; var img_ctr = document.getElementById('satellite_image_container'); var img = img_ctr.getElementsByTagName('img')[0]; var play_order = 0; var self = this; this.init = function() { setInterval("self.update()", 1000); }; this.update = function() { img.src = 'http://www.cwb.gov.tw' + s1p_val[play_order][1]; play_order = (play_order + 1) % data.length; }; this.init(); }(); </script> </body> </html> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.117.213.48

05/08 01:36, , 1F
謝謝chph~ 原來可以這樣用
05/08 01:36, 1F
文章代碼(AID): #1A0neqdP (Ajax)
文章代碼(AID): #1A0neqdP (Ajax)