將iframe和flash轉成使用外部javascript導入
大部份的網路廣告商和web2.0的工具,都會提供javascript的外部導入連結(.js),方便使用者放置在自己的網站或部落格中…但如果把它提供的js檔抓下來分析,就會發現最後常會轉成輸出iframe、flash或是其它程式檔。

這樣的做法,通常是為簡化連結語法(跟flash的語法比要短得多)或是增加一些輸出控制,另外,支援javascript的BSP,也比支援iframe來得多。
拿funp的推文按鈕funp_button.js為例:
var button_dimension = {
1 : {'w' : 60, 'h': 55 },
2 : {'w' : 60, 'h': 69 },
3 : {'w' : 80, 'h': 15 },
4 : {'w' : 91, 'h': 17 },
5 : {'w' : 95, 'h': 22 },
6 : {'w' :115, 'h': 22 },
7 : {'w' : 60, 'h': 66 },
8 : {'w' :100, 'h': 34 },
9 : {'w' :106, 'h': 55 },
10 : {'w' : 60, 'h': 55 },
11 : {'w' :100, 'h': 20 },
12 : {'w' : 80, 'h': 15 },
13 : {'w' : 80, 'h': 15 }
};
function funp_genButton(url,style) {
if (!style) style = 1;
if (!url) url='';
else url="?url="+encodeURIComponent(url);
//注意這裡,輸出iframe
document.write('');
}
如果想讓自己的flash或是iframe也能使用js來導入,就要把它轉成javascript的格式,用document.write輸出
(1) 比方說底下這個iframe:
<iframe src="https://www.diimii.com/wp-monster/pr_interface.php?pr_code=uz437qO5MdtT5BJLiuiR3hT0RR6578&cols=2&rows=2&type=1&category=0&price1=0&price2=0&sp=0&adult=&sadult=0&keyword=&bgcolor=FFFFFF&page=0&login=sunho&webapipassword=2aa3a721693697a4827156a311810284" width="330" height="430" marginheight="0" marginwidth="0" scrolling="no" frameborder="0"></iframe>
(2) 用這工具:HTML to JavaScript Convertor
(3) 得到javascript的輸出格式
function writeJS(){
var str='';
str+='<iframe src="http:\\/\\/www.diimii.com\\/wp-monster\\/pr_interface.php?pr_code=uz437qO5MdtT5BJLiuiR3hT0RR6578&cols=2&rows=2&type=1&category=0&price1=0&price2=0&sp=0&adult=&sadult=0&keyword=&bgcolor=FFFFFF&page=0&login=sunho&webapipassword=2aa3a721693697a4827156a311810284" width="330" height="430" marginheight="0" marginwidth="0" scrolling="no" frameborder="0"><\\/iframe>';
document.write(str);
}
writeJS();
(4) 複製上述內容,把它存為一個新檔如:andy_monster.js
(5) 在網站上使用它,搞定
<script type="text/javascript" src="http://js.diimii.com/01/andy_monster.js"></script>
喔喔原來如此啊,又學到一招了
還不錯用喔 謝謝