FSCommand函數用法(五)

將頁面設爲首頁和加入收藏夾
 將頁面設爲首頁和加入收藏夾
 【 用getURL的方法 】

 設爲首頁: 
 on (release) { 
 getURL("javascript:void(document.links.style.behavior=url(#default#homepage));void document.links.setHomePage(http://www.flash8.net/')", "_self", "POST"); 
 } 

 注意要將網頁中的flash的ID號命名爲"links"

 加入收藏夾: 
 on (release) { 
 getURL("javascript:void window.external.AddFavorite(http://www.flash8.net',閃吧);", "_self", "POST"); 
 } 

 下面有個例子

 
  點擊瀏覽該文件

 【用fscommand的方法】

 1,先在flash的按鈕上添加代碼: 

 首頁: 
 on (release) { 
 fscommand("setHomePage", "http://www.flash8.net";;;;); 
 } 

 收藏夾: 
 on (release) { 
 fscommand("addFavorite", "http://www.flash8.net|閃吧"); 
 } 

 然後在發佈設置中選擇flash with fscommand,發佈成html 

 2,修改html: 

 找到 
 // Handle all the the FSCommand messages in a Flash movie 
 function sethomepage_DoFSCommand(command, args) { 
 } 
 這一段,修改成: 
 // Handle all the the FSCommand messages in a Flash movie 
 function sethomepage_DoFSCommand(command, args) { 
 var sethomepageObj = InternetExplorer ? sethomepage : document.sethomepage; 
 if (command == "setHomePage") { 
 document.links[0].style.behavior = "url(#default#homepage)"; 
 document.links[0].setHomePage(args); 
 } else if (command == "addFavorite") { 
 args = args.split("|"); 
 window.external.AddFavorite(args[0], args[1]); 
 } 
 } 

 最後,如果html裏一個鏈接都沒有,還需在<SCRIPT LANGUAGE=javascript>這句的前面添加一句<a href="javascript:"></a>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章