设为首页和添加收藏的Javascript代码
设为首页和添加收藏的Javascript代码,兼容性还可以,各种主流浏览器都测试通过了。
function addfavorite(){//加入收藏
if (document.all){
window.external.addFavorite("http://"+document.location.host+"/",document.title);
}else if (window.sidebar){
window.sidebar.addPanel(document.title,"http://"+document.location.host+"/", "");
}
}
//设为首页IE下可以,其他浏览器不稳定。
function addhomepage(){if(document.all){document.body.style.behavior='url(#default#homepage)';document.body.setHomePage('http://'+document.location.host+'/');}else{document.body.setHomePage('http://'+document.location.host+'/');}}
//推荐使用。
function SetHomepage(){//设为首页
if(document.all){
document.body.style.behavior="url(#default#homepage)";
document.body.setHomePage("http://"+document.location.host+"/");
}
else if(window.sidebar){
if(window.netscape){
try{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
catch(e){
alert("您的浏览器未启用[设为首页]功能,开启方法:先在地址栏内输入about:config,然后将项 signed.applets.codebase_principal_support 值该为true即可");
}
}
var prefs=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref("browser.startup.homepage","http://"+document.location.host+"/");
}
}
<a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="SetHomepage()">设为首页</a>
<a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="addfavorite()">加入收藏</a>
相关文档:
WebService文件:
[WebMethod]
public int DoMulti(int num1,int num2)
{
int result;
result = num1 * num2;
return result;
}
ASPX文件:
<%@ Page language="c#" Codebehind="Javascript.aspx.cs" AutoEventWireup="false" Inherits=" ......
转化为Boolean类型
所有JavaScript中的值都能隐式的转化为Boolean类型,比如:
0 == false; // true
1 == true; // true
'' == false // true
null == false // true
但是这些值都不是Boolean类型。
因此当我们使用三个等 ......
Js代码
<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="wmp" >
<param name="URL" value="" /> ......
Js代码
<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="wmp" >
<param name="URL" value="" /> ......
1.如何获取表单<select>域的选择部分的文本?
<form name="a">
<select name="a" size="1" onchange="_sel(this)">
<option value="a">1</option>
<option value="b">2</option>
<option value="c">3</option>
</select>
</form&g ......