代码
 //动态生成表单
    function getNewSubmitForm(sid){             //动态生成表单form

     
var submitForm = document.createElement("FORM");

     document.body.appendChild(submitForm);

     submitForm.id
=sid;                                  //表单的id

     submitForm.method 
= "POST";                //表单的提交方式

     submitForm.target
="_blank";

     
return submitForm;

    }
    
//回车事件
     function enterIn(obj,evt){
      
var evt=evt?evt:(window.event?window.event:null);//兼容IE和FF
      if (evt.keyCode==13){      
          baiduSearch();
    }
    }
    
    
//加为收藏
function AddFavorite(sURL, sTitle)
    {
        
try
        {
            window.external.addFavorite(sURL, sTitle);
        }
        
catch (e)
        {
            
try
            {
                window.sidebar.addPanel(sTitle, sURL, 
"");
            }
            
catch (e)
            {
                alert(
"加入收藏失败,请使用Ctrl+D进行添加");
            }
        }
    }
      
//设为首页
   function Homepage() 
   {
        
if (document.all) 
        {
            document.body.style.behavior 
= 'url(#default#homepage)';

            document.body.setHomePage(window.location.href);
        }
        
else if (window.sidebar) 
        {
            
if (window.netscape) 
            {
                
try 
                {
                    netscape.security.PrivilegeManager.enablePrivilege(
"UniversalXPConnect");
                }
                
catch (e) 
                {
                    alert(
"该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");
                   
// history.go(-1);   //这里我用firefox测试的时候出错,我把它注释掉,改成 return false;
                   return false;
                }
            }
            
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref(
'browser.startup.homepage', window.location.href);
        }
    }   

 

posted on 2010-12-10 11:00  大江  阅读(212)  评论(0编辑  收藏  举报