ÉèΪÊ×Ò³ºÍÌí¼ÓÊղصÄ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=" ......
1.ʹÓà ʹÓÃResponse.Write£¬ÕâÖÖ·½·¨»á°ÑJS´úÂëдÔÚÒ³ÃæµÄ×²¿(µÄÇ°Ãæ)£º
2. ʹÓ㺠page.ClientScript.RegisterStartupScript£¨£©£» ÕâÖÖ·½·¨»á°ÑJS´úÂëǶÈëÔÚÒ³ÃæµÄµ×²¿¡¢±íµ¥µÄ×îºó (Ç°Ãæ)£¬ÊÊÓÃÓÚÒªÔÚÒ³Ãæ¿Ø¼þ¼ÓÔØÍê³ÉºóÔËÐеÄJS´úÂë
3.ʹÓÃRegisterClientScriptBlock£¨£©£»ÕâÖÖ·½·¨»á°ÑJS´úÂëǶÈëÔÚÒ³ÃæµÄ¶¥²¿¡¢ ......
jsÑéÖ¤±íµ¥´óÈ«
1. ³¤¶ÈÏÞÖÆ
<script>
function test()
{
if(document.a.b.value.length>50)
{
alert("²»Äܳ¬¹ý50¸ö×Ö·û£¡");
document.a.b.focus();
return false;
}
}
</script>
<form name=a onsubmit="return test()">
<textarea name="b" cols="40" wrap="VIRTUAL" rows="6"&g ......
replace()×î¼òµ¥µÄËãÊÇÄÜÁ¦¾ÍÊǼòµ¥µÄ×Ö·ûÌæ»»¡£ ʾÀý´úÂëÈçÏ£º
ËüÖ»Ìæ»»ÁËÊ××Öĸ¡£µ«Èç¹û¼ÓÉÏÕýÔò±í´ïʽ½á¹û¾Í²»Ò»ÑùÁË£¡replace()Ö§³ÖÕýÔò±í´ïʽ£¬Ëü¿ÉÒÔ°´ÕÕÕýÔò±í´ïʽµÄ¹æÔòÆ¥Åä×Ö·û»ò×Ö·û´®£¬È»ºó¸øÓèÌæ»»£¡ ×¢Ò⣺±»Ìæ»»µÄ²¿·Ö²»ÓüÓË«ÒýºÅ.
ÕâÑù»¹ÊÇÖ»Ìæ»»Á˵ÚÒ»¸ö×Öĸa¡£
ÓÉÉÏ¿ÉÖª£¬µ±ÕýÔò±í´ïʽÓÐ"g"±ê־ʱ£¬´ ......
Js´úÂë
<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="wmp" >
<param name="URL" value="" /> ......