常用:javascript字符串函数 收藏
concat
将两个或多个字符的文本组合起来,返回一个新的字符串。
var a = "hello";
var b = ",world";
var c = a.concat(b);
alert(c);
//c = "hello,world"
indexOf
返回字符串中一个子串第一处出现的索引(从左到右搜索)。如果没有匹配项,返回 -1 。
var index1 = a.indexOf("l");
//index1 = 2
var index2 = a.indexOf("l",3);
//index2 = 3
charAt
返回指定位置的字符。
var get_char = a.charAt(0);
//get_char = "h"
lastIndexOf
返回字符串中一个子串最后一处出现的索引(从右到左搜索),如果没有匹配项,返回 -1 。
var index1 = lastIndexOf('l');
//index1 = 3
var index2 = lastIndexOf('l',2)
//index2 = 2
match
检查一个字符串匹配一个正则表达式内容,如果么有匹配返回 null。
var re = new RegExp(/^\w+$/);
var is_alpha1 = a.match(re);
//is_alpha1 = "hello"
var is_alpha2 = b.match(re);
//is_alpha2 = null
substring
返回字符串的一个子串,传入参数是起始位置和结束位置。
var sub_string1 = a.substring(1);
//sub_string1 = "ello"
var sub_string2 = a.substring(1,4);
......
Javascript网页打印大全
2010-04-09 09:30
普通打印(整页打) 打印网页内部分内容(自定义) 打印去掉/添加页眉页脚 使用外部控件/方法实现多功能打印 打印背景
以上为代码控制
设置“页面设置”实现打印参数设置(Window系统图文版)
一、普通打印(整页打)
这个不用多说,直接用
引用:
window.print();
二、打印网页内部分内容(自定义)
分三种方法实现
1、用css控制
引用:
@media print
.a {display:block}
.b {display:hidden}
把你不想打印的部分class设为b
首先在网页中添加:
引用:
<OBJECT id="WebBrowser" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"
VIEWASTEXT>
</OBJECT>
然后就可以依次加入功能按钮了:
引用:
<input type="bu ......
完全打开页面后,在该页的在IE地址栏 或 按Ctrl+O 输入以下代码,回车,就可以得到相应的效果:
1.显示网页中的所有图片
javascript:Ai7Mg6P='';for%20(i7M1bQz=0;i7M1bQz<document.images.length;i7M1bQz++){Ai7Mg6P+='<img%20src='+document.images[i7M1bQz].src+'><br>'};if(Ai7Mg6P!=''){document.write('<center>'+Ai7Mg6P+'</center>');void(document.close())}else{alert('No%20images!')}
2.显示网页中除图片的其他
javascript:for(jK6bvW=0;jK6bvW<document.images.length;jK6bvW++){void(document.images[jK6bvW].style.visibility='hidden')}
3.显示网页源代码(对于加密过的可以直接显示其加密前的源代码)
javascript:s=document.documentElement.outerHTML;document.write('<body></body>');document.body.innerText=s;
4.网页放大1.5倍
javascript:void(s=document.body.style);void(z=s.getAttribute('zoom'));if(z){s.setAttribute('zoom',(parseInt(z)+50)+'%');}else s.setAttribute('zoom','150%')
5.网页缩小0.5倍
javascript:void(s=document.body.style);void(z=s.getAttribute('zoom'));if(z){s.s ......
通过xmlhttp+webservice(原始方法)
原文地址:http://netboy.cnblogs.com/archive/2006/02/18/333260.html
view plaincopy to clipboardprint?
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[webservice(namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service ()
{
//uncomment the following line if using designed components
//InitializeComponent();
}
[webmethod]
public string SayHelloTo(string Name)
  ......
在数据绑定事件中写如下代码:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row .RowType == DataControlRowType .DataRow)//判断是否为数据行
{
//在点击删除时,弹出提示对话框
LinkButton lb = e.Row.FindControl("LinkButton1") as LinkButton;
lb.Attributes.Add("onclick","return confirm('确认?')");//是否触发onclick事件
//给数据行加载样式(用javascript)(光棒效果)
e.Row.Attributes.Add("onmouseover", "aa=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Row.Attributes.Add("onmouseout","this.style.backgroundColor=aa");
}
}
......
javascript实现弹出带透明效果的可拖动图层
最经因为需要一个弹出图层效果,弹出图层倒是容易实现,但具有拖动效果却不知怎么去实现,在网上最终找到了一个需要的效果,代码也不多,一看代码的精炼,知道原作者应该是javascript高手级别的人,现在决定借来一用,我把它略加美化后,看上去效果还很不错。
于是把它记下来,以便今后方便使用。
function openDIV(){
var titleheight = "22px"; // 提示窗口标题高度
var bordercolor = "#000099"; // 提示窗口的边框颜色
var titlecolor = "#ffff00"; // 提示窗口的标题颜色
var titlebgcolor = "#000099"; // 提示窗口的标题背景色
var bgcolor = "#000"; // 提示内容的背景色
var w=600; &nbs ......