当前位置:首页 > 代码 > 正文

常用的网页代码(现成的网页代码)

admin 发布:2022-12-19 20:03 180


今天给各位分享常用的网页代码的知识,其中也会对现成的网页代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

网页代码大全

!-- saved from url=(0013)about:internet --

网页常用HTML代码大全(二)(续)

marquee.../marquee普通卷动

marquee behavior=slide.../marquee滑动

marquee behavior=scroll.../marquee预设卷动

marquee behavior=alternate.../marquee来回卷动 marquee direction=down.../marquee向下卷动

marquee direction=up.../marquee向上卷动

marquee direction=right/marquee向右卷动

marquee direction=left/marquee向左卷动

marquee loop=2.../marquee卷动次数

marquee width=180.../marquee设定宽度

marquee height=30.../marquee设定高度

marquee bgcolor=FF0000.../marquee设定背景颜色 marquee scrollamount=30.../marquee设定卷动距离 marquee scrolldelay=300.../marquee设定卷动时间

1/54

!字体效果

h1.../h1标题字(最大)

h6.../h6标题字(最小)

b.../b粗体字

strong.../strong粗体字(强调)

i.../i斜体字

em.../em斜体字(强调)

dfn.../dfn斜体字(表示定义)

u.../u底线

ins.../ins底线(表示插入文字)

strike.../strike横线

s.../s删除线

del.../del删除线(表示删除)

kbd.../kbd键盘文字

tt.../tt 打字体

xmp.../xmp固定宽度字体(在文件中空白、换行、定位功能有效)

plaintext.../plaintext固定宽度字体(不执行标记符号)

2/54

listing.../listing 固定宽度小字体

font color=00ff00.../font字体颜色

font size=1.../font最小字体

font style =font-size:100 px.../font无限增大 !区断标记

hr水平线

hr size=9水平线(设定大小)

hr width=80%水平线(设定宽度)

hr color=ff0000水平线(设定颜色)

br(换行)

nobr.../nobr水域(不换行)

p.../p水域(段落)

center.../center置中

!连结格式

base href=地址(预设好连结路径)

a href=地址/a外部连结

a href=地址 target=_blank/a外部连结(另开新窗口) a href=地址 target=_top/a外部连结(全窗口连结)

3/54

a href=地址 target=页框名/a外部连结(在指定页框连结) !贴图/音乐

img src=图片地址贴图

img src=图片地址 width=180设定图片宽度

img src=图片地址 height=30设定图片高度

img src=图片地址 alt=提示文字设定图片提示文字 img src=图片地址 border=1设定图片边框

bgsound src=MID音乐文件地址背景音乐设定

!表格语法

table aling=left.../table表格位置,置左

table aling=center.../table表格位置,置中

table background=图片路径.../table背景图片的URL=就是路径网址

table border=边框大小.../table设定表格边框大小(使用数字)

table bgcolor=颜色码.../table设定表格的背景颜色 table borderclor=颜色码.../table设定表格边框的颜色

4/54

table borderclordark=颜色码.../table设定表格暗边框的颜色

table borderclorlight=颜色码.../table设定表格亮边框的颜色

table cellpadding=参数.../table指定内容与网格线之间的间距(使用数字)

table cellspacing=参数.../table指定网格线与网格线之间的距离(使用数字)

table cols=参数.../table指定表格的栏数

table frame=参数.../table设定表格外框线的显示方式 table width=宽度.../table指定表格的宽度大小(使用数字)

table height=高度.../table指定表格的高度大小(使用数字)

td colspan=参数.../td指定储存格合并栏的栏数(使用数字)

td rowspan=参数.../td指定储存格合并列的列数(使用数字)

!分割窗口

常用代码合集

1、禁止手机睡眠

[UIApplication sharedApplication].idleTimerDisabled = YES;

2、隐藏某行cell

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

// 如果是你需要隐藏的那一行,返回高度为0

    if(indexPath.row == YouWantToHideRow){

        return 0;

    }  return 44;

}

// 然后再你需要隐藏cell的时候调用

[self.tableView beginUpdates];

[self.tableView endUpdates];

3、禁用button高亮

button.adjustsImageWhenHighlighted = NO;

4、tableview遇到这种报错failed to obtain a cell from its dataSource

是因为你的cell被调用的早了。先循环使用了cell,后又创建cell。顺序错了

可能原因:1、xib的cell没有注册 2、内存中已经有这个cell的缓存了(也就是说通过你的cellId找到的cell并不是你想要的类型),这时候需要改下cell的标识

5、去除数组中重复的对象

NSArray *newArr = [oldArr valueForKeyPath:@“@distinctUnionOfObjects.self"];

6、动态修改ableView的tableHeaderView或者tableFooterView的高度

开发中如果要动态修改tableView的tableHeaderView或者tableFooterView的高度,需要给tableView重新设置,而不是直接更改高度。正确的做法是重新设置一下tableView.tableFooterView = 更改过高度的view。为什么?其实在iOS8以上直接改高度是没有问题的,在iOS8中出现了contentSize不准确的问题,这是解决办法。

7、collectionView的内容小于其宽高的时候是不能滚动的,设置可以滚动:

collectionView.alwaysBounceHorizontal = YES;

collectionView.alwaysBounceVertical = YES;

8、颜色转图片

+ (UIImage *)cl_imageWithColor:(UIColor *)color {

  CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);

  UIGraphicsBeginImageContext(rect.size);

  CGContextRef context = UIGraphicsGetCurrentContext();

  CGContextSetFillColorWithColor(context, [color CGColor]);

  CGContextFillRect(context, rect);

  UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

  UIGraphicsEndImageContext();

  return image;

}

9、view设置圆角

#define ViewBorderRadius(View, Radius, Width, Color)

[View.layer setCornerRadius:(Radius)];\

[View.layer setMasksToBounds:YES];\

[View.layer setBorderWidth:(Width)];\

[View.layer setBorderColor:[Color CGColor]] // view圆角

10、强/弱引用

#define WeakSelf(type)  __weak typeof(type) weak##type = type; // weak

#define StrongSelf(type)  __strong typeof(type) type = weak##type; // strong

11、由角度转换弧度

#define DegreesToRadian(x) (M_PI * (x) / 180.0)

12、由弧度转换角度

#define RadianToDegrees(radian) (radian*180.0)/(M_PI)

13、获取app缓存大小

- (CGFloat)getCachSize {

    NSUInteger imageCacheSize = [[SDImageCache sharedImageCache] getSize];

    //获取自定义缓存大小

    //用枚举器遍历 一个文件夹的内容

    //1.获取 文件夹枚举器

    NSString *myCachePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];

    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:myCachePath];

    __block NSUInteger count = 0;

    //2.遍历

    for (NSString *fileName in enumerator) {

        NSString *path = [myCachePath stringByAppendingPathComponent:fileName];

        NSDictionary *fileDict = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil];

        count += fileDict.fileSize;//自定义所有缓存大小

    }

    // 得到是字节  转化为M

    CGFloat totalSize = ((CGFloat)imageCacheSize+count)/1024/1024;

    return totalSize;

}

14、清理app缓存

- (void)handleClearView {

    //删除两部分

    //1.删除 sd 图片缓存

    //先清除内存中的图片缓存

    [[SDImageCache sharedImageCache] clearMemory];

    //清除磁盘的缓存

    [[SDImageCache sharedImageCache] clearDisk];

    //2.删除自己缓存

    NSString *myCachePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];

    [[NSFileManager defaultManager] removeItemAtPath:myCachePath error:nil];

}

15、几个常用权限判断

    if ([CLLocationManager authorizationStatus] ==kCLAuthorizationStatusDenied) {

        NSLog(@"没有定位权限");

    }

    AVAuthorizationStatus statusVideo = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];

    if (statusVideo == AVAuthorizationStatusDenied) {

        NSLog(@"没有摄像头权限");

    }

    //是否有麦克风权限

    AVAuthorizationStatus statusAudio = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];

    if (statusAudio == AVAuthorizationStatusDenied) {

        NSLog(@"没有录音权限");

    }

    [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {

        if (status == PHAuthorizationStatusDenied) {

            NSLog(@"没有相册权限");

        }

    }];

16、长按复制功能

- (void)viewDidLoad

{

    [self.view addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(pasteBoard:)]];

}

- (void)pasteBoard:(UILongPressGestureRecognizer *)longPress {

    if (longPress.state == UIGestureRecognizerStateBegan) {

        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];

        pasteboard.string = @"需要复制的文本";

    }

}

17、image拉伸

+ (UIImage *)resizableImage:(NSString *)imageName

{

    UIImage *image = [UIImage imageNamed:imageName];

    CGFloat imageW = image.size.width;

    CGFloat imageH = image.size.height;

    return [image resizableImageWithCapInsets:UIEdgeInsetsMake(imageH * 0.5, imageW * 0.5, imageH * 0.5, imageW * 0.5) resizingMode:UIImageResizingModeStretch];

}

18、JSON字符串转字典

+ (NSDictionary *)parseJSONStringToNSDictionary:(NSString *)JSONString {

    NSData *JSONData = [JSONString dataUsingEncoding:NSUTF8StringEncoding];

    NSDictionary *responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableLeaves error:nil];

    return responseJSON;

}

19、画水印

// 画水印

- (void) setImage:(UIImage *)image withWaterMark:(UIImage *)mark inRect:(CGRect)rect

{

    if ([[[UIDevice currentDevice] systemVersion] floatValue] = 4.0)

    {

        UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0);

    }

    //原图

    [image drawInRect:self.bounds];

    //水印图

    [mark drawInRect:rect];

    UIImage *newPic = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    self.image = newPic;

}

20、身份证号验证

- (BOOL)validateIdentityCard {

    BOOL flag;

    if (self.length = 0) {

        flag = NO;

        return flag;

    }

    NSString *regex2 = @"^(\\d{14}|\\d{17})(\\d|[xX])$";

    NSPredicate *identityCardPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex2];

    return [identityCardPredicate evaluateWithObject:self];

}

21、移除字符串中的空格和换行

+ (NSString *)removeSpaceAndNewline:(NSString *)str {

    NSString *temp = [str stringByReplacingOccurrencesOfString:@" " withString:@""];

    temp = [temp stringByReplacingOccurrencesOfString:@"\r" withString:@""];

    temp = [temp stringByReplacingOccurrencesOfString:@"\n" withString:@""];

    return temp;

}

22、判断字符串中是否有空格

+ (BOOL)isBlank:(NSString *)str {

    NSRange _range = [str rangeOfString:@" "];

    if (_range.location != NSNotFound) {

        //有空格

        return YES;

    } else {

        //没有空格

        return NO;

    }

}

22、获取一个视频的第一帧图片

    NSURL *url = [NSURL URLWithString:filepath];

    AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:url options:nil];

    AVAssetImageGenerator *generate1 = [[AVAssetImageGenerator alloc] initWithAsset:asset1];

    generate1.appliesPreferredTrackTransform = YES;

    NSError *err = NULL;

    CMTime time = CMTimeMake(1, 2);

    CGImageRef oneRef = [generate1 copyCGImageAtTime:time actualTime:NULL error:err];

    UIImage *one = [[UIImage alloc] initWithCGImage:oneRef];

    return one;

23、获取视频的时长

+ (NSInteger)getVideoTimeByUrlString:(NSString *)urlString {

    NSURL *videoUrl = [NSURL URLWithString:urlString];

    AVURLAsset *avUrl = [AVURLAsset assetWithURL:videoUrl];

    CMTime time = [avUrl duration];

    int seconds = ceil(time.value/time.timescale);

    return seconds;

}

24、UILabel设置内边距

子类化UILabel,重写drawTextInRect方法

- (void)drawTextInRect:(CGRect)rect {

    // 边距,上左下右

    UIEdgeInsets insets = {0, 5, 0, 5};

    [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];

}

25、UILabel设置文字描边

子类化UILabel,重写drawTextInRect方法

- (void)drawTextInRect:(CGRect)rect

{

    CGContextRef c = UIGraphicsGetCurrentContext();

    // 设置描边宽度

    CGContextSetLineWidth(c, 1);

    CGContextSetLineJoin(c, kCGLineJoinRound);

    CGContextSetTextDrawingMode(c, kCGTextStroke);

    // 描边颜色

    self.textColor = [UIColor redColor];

    [super drawTextInRect:rect];

    // 文本颜色

    self.textColor = [UIColor yellowColor];

    CGContextSetTextDrawingMode(c, kCGTextFill);

    [super drawTextInRect:rect];

}

26、在状态栏增加网络请求的菊花,类似safari加载网页的时候状态栏菊花

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

27、修改cell.imageView的大小

UIImage *icon = [UIImage imageNamed:@""];

CGSize itemSize = CGSizeMake(30, 30);

UIGraphicsBeginImageContextWithOptions(itemSize, NO ,0.0);

CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);

[icon drawInRect:imageRect];

cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

28、为一个view添加虚线边框

CAShapeLayer *border = [CAShapeLayer layer];

    border.strokeColor = [UIColor colorWithRed:67/255.0f green:37/255.0f blue:83/255.0f alpha:1].CGColor;

    border.fillColor = nil;

    border.lineDashPattern = @[@4, @2];

    border.path = [UIBezierPath bezierPathWithRect:view.bounds].CGPath;

    border.frame = view.bounds;

    [view.layer addSublayer:border];

29、UITextView中打开或禁用复制,剪切,选择,全选等功能

// 继承UITextView重写这个方法

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender

{

// 返回NO为禁用,YES为开启

    // 粘贴

    if (action == @selector(paste:)) return NO;

    // 剪切

    if (action == @selector(cut:)) return NO;

    // 复制

    if (action == @selector(copy:)) return NO;

    // 选择

    if (action == @selector(select:)) return NO;

    // 选中全部

    if (action == @selector(selectAll:)) return NO;

    // 删除

    if (action == @selector(delete:)) return NO;

    // 分享

    if (action == @selector(share)) return NO;

    return [super canPerformAction:action withSender:sender];

}

30、tableViewCell分割线顶到头

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

    [cell setSeparatorInset:UIEdgeInsetsZero];

    [cell setLayoutMargins:UIEdgeInsetsZero];

    cell.preservesSuperviewLayoutMargins = NO;

}

- (void)viewDidLayoutSubviews {

    [self.tableView setSeparatorInset:UIEdgeInsetsZero];

    [self.tableView setLayoutMargins:UIEdgeInsetsZero];

}

程序员必须知道的HTML常用代码有哪些

html+css代码

文本设置

1、font-size: 字号参数

2、font-style: 字体格式

3、font-weight: 字体粗细

4、颜色属性

color: 参数

注意使用网页安全色

超链接设置

text-decoration: 参数

主要用途是改变浏览器显示文字链接时的下划线。

参数取值范围:

underline:为文字加下划线

overline:为文字加上划线

line-through:为文字加删除线

blink:使文字闪烁

none:不显示上述任何效果

背景

1、背景颜色

background-color: 参数

2、背景图片

background-image: url(URL)

URL就是背景图片的存放路径,none表示无。

3、背景图片重复

background-repeat: 参数

参数取值范围 :

no-repeat:不重复平铺背景图片

repeat-x:使图片只在水平方向上平铺

repeat-y:使图片只在垂直方向上平铺

如果不指定背景图片重复属性,浏览器默认的是背景图片向水平、垂直两个方向上平铺。

4、背景图片固定

背景图片固定控制背景图片是否随网页的滚动而滚动。如果不设置背景图片固定属性,浏览器默认背景图片随网页的滚动而滚动。为了避免过于花哨的背景图片在滚动时转移浏览者的注意力,一般都设为固定

background-attachment: 参数

参数取值范围:

fixed:网页滚动时,背景图片相对于浏览器的窗口而言,固定不动

scroll:网页滚动时,背景图片相对于浏览器的窗口而言,一起滚动

区块

1、单词间距

word-spacing: 间隔距离

2、字母间距

letter-spacing: 字母间距

3、文本对齐

text-align: 参数

参数的取值:

left:左对齐

right:右对齐

center:居中对齐

justify:相对左右对齐

4、垂直对齐

vertical-align: 参数

top:顶对齐

bottom:底对齐

text-top:相对文本顶对齐

text-bottom:相对文本底对齐

baseline:基准线对齐

middle:中心对齐

sub:以下标的形式显示

super:以上标的形式显示

5、文本缩进

text-indent: 缩进距离

12px相当于一个文字距离

6、空格

white-space: 参数

normal 正常

pre 保留

nowrap 不换行

7、显示样式

display: 参数

参数取值范围:

block:块级元素,在对象前后都换行

inline:在对象前后都不换行

list-item:在对象前后都换行,增加了项目符号

none:无显示

方框

1、height 高度

2、width 宽度

3、padding 内边距

4、margin 外边距

5、float(浮动):可以让块级元素在一行中排列,例如横向菜单。

6、clear 清除浮动

边框

1、样式

border style 参数

边框样式的参数:

none:无边框

dotted:边框为点线

dashed:边框为长短线

solid:边框为实线

double:边框为双线

2、宽度

border width 参数

3、颜色

border color 参数

列表

list-style-type 列表样式

不同浏览器的列表符可能不相同,可能会影响到网页,所以网页中的列表大多都是由背景图片显示。

控制用户界面的样式

鼠标

cursor:鼠标形状参数

CSS鼠标形状参数表:

鼠标形状:CSS代码

style="cursor:hand"  手形

style="cursor:crosshair" 十字形

style="cursor:text"  文本形

style="cursor:wait"  沙漏形

style="cursor:move" 十字箭头形:

style="cursor:help"  问号形

style="cursor:e-resize"  右箭头形

style="cursor:n-resize"  上箭头形

style="cursor:nw-resize" 左上箭头形

style="cursor:w-resize"  左箭头形

style="cursor:s-resize"  下箭头形

style="cursor:se-resize" 右下箭头形

style="cursor:sw-resize" 左下箭头形

HTML常用代码之:结构性定义

文件类型HTML/HTML (放在档案的开头与结尾)

文件主题TITLE/TITLE (必须放在「文头」区块内)

文头HEAD/HEAD (描述性资料,像是「主题」)

文体BODY/BODY (文件本体)

标题H?/H? (从1到6,有六层选择)

标题的对齐 H?ALIGN=LEFT|CENTER|RIGHT/H?

区分DIV/DIV

区分的对齐 DIVALIGN=LEFT|RIGHT|CENTER|JUSTIFY/DIV

引文区块BLOCKQUOTE/BLOCKQUOTE (通常会内缩)

强调EM/EM (通常会以斜体显示)

特别强调STRONG/STRONG (通常会以加粗显示)

引文CITE/CITE (通常会以斜体显示)

码CODE/CODE (显示原始码之用)

样本SAMP/SAMP

键盘输入KBD/KBD

变数VAR/VAR

定义DFN/DFN (有些浏览器不提供)

地址 ADDRESS/ADDRESS

大字BIG/BIG

小字SMALL/SMALL

与外观相关的标签(作者自订的表现方式)

加粗B/B

斜体I/I

底线U/U (尚有些浏览器不提供)

删除线S/S (尚有些浏览器不提供)

下标SUB/SUB

上标SUP/SUP

打字机体TT/TT (用单空格字型显示)

预定格式PRE/PRE (保留文件中空格的大小)

预定格式的宽度PRE WIDTH=?/PRE(以字元计算)

向中看齐CENTER/CENTER (文字与图片都可以)

闪耀BLINK/BLINK (有史以来最被嘲弄的标签)

字体大小 FONTSIZE=?/FONT(从1到7)

改变字体大小 FONTSIZE=+|-?/FONT

基本字体大小 BASEFONTSIZE=? (从1到7; 内定为3)

字体颜色 FONTCOLOR="#$$"/FONT($$为颜色代码)

HTML常用代码之:修改页面的实用性HTML代码

贴图:img src="图片地址"

加入连接:a href="所要连接的相关地址"写上你想写的字/a

在新窗口打开连接:a href="相关地址" target="_blank"写上要写的字/a

移动字体(走马灯):marquee写上你想写的字/marquee

字体加粗:b写上你想写的字/b

字体斜体:i写上你想写的字/i

字体下划线: u写上你想写的字/u

字体删除线: s写上你想写的字/s

字体加大: big写上你想写的字/big

字体控制大小:h1写上你想写的字/h1 (其中字体大小可从h1-h5,h1最大,h5最小)

更改字体颜色:font color="#value"写上你想写的字/font(其中value值在000000与ffffff(16位进制)之间

消除连接的下划线:a href="相关地址" style="text-decoration:none"写上你想写的字/a

贴音乐:embed src="音乐地址" width="宽度" height="高度" autostart=false

贴flash: embed src="flash地址" width="宽度" height="高度"

贴影视文件:img dynsrc="文件地址" width="宽度" height="高度" start=mouseover

换行:br

段落:p段落/p

原始文字样式:pre正文/pre

换帖子背景:body background="背景图片地址"

固定帖子背景不随滚动条滚动:body background="背景图片地址" body bgproperties=fixed

定制帖子背景颜色:body bgcolor="#value"(value值见10)

帖子背景音乐:bgsound="背景音乐地址" loop=infinite

贴网页:iframe. src="相关地址" width="宽度" height="高度"/iframe

HTML常用代码之:常常会遇到的问题

点击关闭窗口

a href="javascript.:top.window.close();"点击关闭窗口/a!

请问如何去掉主页右面的滚动条?

body scroll="no"

body style="overflow-y:hidden"

如何做到让一个网页自动关闭.

html

head

OBJECT id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"

param name="Command" value="Close"

/object

/head

body

这个窗口会在10秒过后自动关闭,而且不会出现提示. /body

如何在不刷新页面的情况下刷新css?

style

button{ color:#000000;}

/style

button nclick=document.styleSheets[0].rules[0].style.color=‘‘‘‘red‘‘‘‘点击按钮直接修改style标签里button选择符使按钮改为红色/button

请问如何让网页自动刷新?

在head部记入META. HTTP-EQUIV="Refresh" c其中20为20秒后自动刷新,你可以更改为任意值。

如何让页面自动刷新?

方法一,用refresh

HTML 代码片段如下:

head

meta. http-equiv="refresh" c

/head

5表示刷新时间

[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

方法二,使用setTimeout控制

img src=/logo.gif

script

function rl(){

document.location.reload()

}

setTimeout(rl,2000)

/SCRIPT

如何让超链接没有下划线

在源代码中的HEAD…/HEAD之间输入如下代码:

style. type="text/css" !--

a { text-decoration: none}

-- /style

请问如何去掉IE的上下滚动条?

body style=‘‘‘‘overflow:scroll;overflow-y:hidden‘‘‘‘

/body

怎样才能把RealPlayer文件在网页做一个试听连接?

embed height=25 src=51js.rm type=audio/x-pn-realaudio-plugin width=50 autostart="false" c

如何用html实现浏览器上后退按钮的功能?

a href="java script.:history.go(-1)"点击后退/a

或者

script history.back() /SCRIPT

HTML常用代码之:你不一定知道的技巧

ncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键

table borderncontextmenu=return(false)tdno/table 可用于Table

body nselectstart="return false" 取消选取、防止复制

onpaste="return false" 不准粘贴

oncopy="return false;" ncut="return false;" 防止复制

link rel="Shortcut Icon"href="favicon.ico" IE地址栏前换成自己的图标

link rel="Bookmark"href="favicon.ico" 可以在收藏夹中显示出你的图标

inputstyle="ime-mode:disabled" 关闭输入法

永远都会带着框架

script. language="JavaScript"!--

if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页

// --/script

防止被人frame.

SCRIPT. LANGUAGE=JAVASCRIPT!--

if (top.location != self.location)top.location=self.location;

// --/SCRIPT

网页将不能被另存为

noscriptiframe.src=*.html/iframe/noscript

查看网页源代码

input type=button value=查看网页源代码

onclick="window.location = "view-source:"+"""

删除时确认

a href="javascript:if(confirm("确实要删除吗?"))location="boos.asp? areyou=删除page=1""删除/a

屏蔽功能键Shift,Alt,Ctrl

script

function look(){

if(event.shiftKey)

alert("禁止按Shift键!");//可以换成ALT CTRL

}

document.onkeydown=look;

/script

网页不会被缓存

META. HTTP-EQUIV="pragma" CONTENT="no-cache"

META. HTTP-EQUIV="Cache-Control"CONTENT="no-cache, must-revalidate"

META. HTTP-EQUIV="expires"CONTENT="Wed, 26 Feb 1997 08:21:57 GMT"

或者META. HTTP-EQUIV="expires"CONTENT="0"

怎样让表单没有凹凸感?

input type=text style="border:1 solid #000000"

input type=text style="border-left:none;border-right:none; border -top:none; border-bottom: 1 solid#000000"/textarea

不要滚动条?

让竖条没有:

body style="overflow:scroll;overflow-y:hidden"

/body

让横条没有:

body style="overflow:scroll;overflow-x:hidden"

/body

两个都去掉?更简单了

body scroll="no"

/body

怎样去掉图片链接点击后,图片周围的虚线?

a href="#"nFocus="this.blur()"img src="logo.jpg"border=0/a

电子邮件处理提交表单

form. name="form1"method="post" action="mailt****@***.com"enctype="text/plain"

input type=submit

/form

在打开的子窗口刷新父窗口的代码里如何写?

window.opener.location.reload()

如何设定打开页面的大小

body nload="top.resizeTo(300,200);"

打开页面的位置bodynload="top.moveBy(300,200);"

在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动

STYLE

body

{background-image:url(logo.gif); background-repeat:no-repeat;

background-position:center;background-attachment: fixed}

/STYLE

检查一段字符串是否全由数字组成

script. language="Javascript"!--

function checkNum(str){return str.match(//D/)==null}

alert(checkNum("1232142141"))

alert(checkNum("123214214a1"))

// --/script

获得一个窗口的大小

document.body.clientWidth; document.body.clientHeight

怎么判断是否是字符

if (/[^/x00-/xff]/g.test(s)) alert("含有汉字");

else alert("全是字符");

TEXTAREA自适应文字行数的多少

textarea rows=1 name=s1 cols=27npropertychange="this.style.posHeight=this.scrollHeight"

/textarea

日期减去天数等于第二个日期

script. language=Javascript

function cc(dd,dadd)

{

//可以加上错误处理

var a = new Date(dd)

a = a.valueOf()

a = a - dadd * 24 * 60 * 60 * 1000

a = new Date(a)

alert(a.getFullYear() + "年" + (a.getMonth() +1) + "月" + a.getDate() + "日")

} cc("12/23/2002",2)

/script

选择了哪一个Radio

HTMLscript. language="vbscript"

function checkme()

for each ob in radio1

if ob.checked then window.alert ob.value

next

end function

/scriptBODY

INPUT name="radio1" type="radio"value="style" checkedStyle.

INPUT name="radio1" type="radio"value="barcode"Barcode

INPUT type="button" value="check"nclick="checkme()"

/BODY/HTML

脚本永不出错

SCRIPT. LANGUAGE="JavaScript"

!-- Hide function killErrors(){return true;} window.onerror = killErrors;// --

/SCRIPT

ENTER键可以让光标移到下一个输入框

input nkeydown="if(event.keyCode==13)event.keyCode=9"

掌握网页代码基本格式

网页代码有固定的基本格式。下面,我们来看看网页代码基本格式是什么样的吧。

01

基本格式如下

html

head

meta http-equiv="Content-Type" content="text/html; charset=utf-8" /

title这里填写标题/title

/style

/head

body

HTML代码

/body

/html

02

标示符

网页代表是用标示名来表示开始和结束的,比如

head/head表示网页的头部

title/title表示网页的名称

body/body表示网页的主体部分

03

段落

p style="color:blue;font-size:20px;"段落/p

04

运行

然后在浏览器中运行,如下图所示:

网页设计常用HTML代码

网页设计常用HTML代码大全

HTML是用来描述网页的一种语言。下面我为大家分享HTML代码,希望对大家学习html代码有帮助!

忽视右键

body oncontextmenu="return false"

body style="overflow-y:hidden"

1.如何几秒后转到别的页面?

META HTTP-EQUIV="Refresh" CONTENT="时间;URL=地址"

2.点击关闭窗口

a href="javascript:top.window.close();"点击关闭窗口/a!

3.请问如何去掉主页右面的滚动条?

body scroll="no"

body style="overflow-y:hidden"

4.请问如何做到让一个网页自动关闭.

html

head

OBJECT id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"

param name="Command" value="Close"

/object

/head

body onload="window.setTimeout(‘‘‘‘closes.Click()‘‘‘‘,10000)"

这个窗口会在10秒过后自动关闭,而且不会出现提示. /body

如何在不刷新页面的情况下刷新css?

style

button{ color:#000000;}

/style

button onclick=document.styleSheets[0].rules[0].style.color=‘‘‘‘red‘‘‘‘点击按钮直接修改style标签里button选择符使按钮改为红色/button

请问如何让网页自动刷新?

在head部记入META HTTP-EQUIV="Refresh" content="20"其中20为20秒后自动刷新,你可以更改为任意值。

5.如何让页面自动刷新?

方法一,用refresh

HTML 代码片段如下:

head

meta http-equiv="refresh" content="5"

/head

5表示刷新时间

[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

方法二,使用setTimeout控制

img src=/logo.gif

script

function rl(){

document.location.reload()

}

setTimeout(rl,2000)

/script

6.如何让超链接没有下划线

在源代码中的HEAD…/HEAD之间输入如下代码:

style type="text/css" !--

a { text-decoration: none}

-- /style

7.请问如何去掉IE的上下滚动条?

body style=‘‘‘‘overflow:scroll;overflow-y:hidden‘‘‘‘

/body

8.怎样才能把RealPlayer文件在网页做一个试听连接?

embed height=25 src=51js.rm type=audio/x-pn-realaudio-plugin width=50 autostart="false" controls="PlayButton"

9.如何用html实现浏览器上后退按钮的功能?

a href="java script:history.go(-1)"点击后退/a

或者

script history.back() /script

10.请问怎么在网页中改变鼠标的箭头形状?

HTML 代码片段如下:

body

a href="#" style="cursor: auto;"auto/abr

a href="#" style="cursor: crosshair "crosshair /abr

a href="#" style="cursor: default "default /abr

a href="#" style="cursor: hand "hand /abr

a href="#" style="cursor: move "move /abr

a href="#" style="cursor: e-resize "e-resize /abr

a href="#" style="cursor: ne-resize "ne-resize /abr

a href="#" style="cursor: nw-resize"nw-resize/abr

a href="#" style="cursor: n-resize"n-resize/abr

a href="#" style="cursor: se-resize"se-resize/abr

a href="#" style="cursor: sw-resize"sw-resize/abr

a href="#" style="cursor: s-resize"s-resize/abr

a href="#" style="cursor: w-resize"w-resize/abr

a href="#" style="cursor: text"text/abr

a href="#" style="cursor: wait"wait/abr

a href="#" style="cursor: help"help/abr

/body

11.怎样不使用页面的缓存?即每一次打开页面时不是调用缓存中的东西

META HTTP-EQUIV="Pragma" CONTENT="no-cache"

12.页面打开时自动弹出一个窗口的代码怎么写?

HTML 代码片段如下:

html

head

titleUntitled Document/title

meta http-equiv="Content-Type" content="text/html; charset=gb2312"

script language="B style="color:black;background-color:#A0FFFF"javascript/B"

!--

function MM_openBrWindow(theURL,winName,features) { //v2.0

window.open(theURL,winName,features);

}

//--

/script

/head

body bgcolor="#FFFFFF" text="#000000" onLoad="MM_openBrWindow(‘‘‘‘‘‘‘‘,‘‘‘‘,‘‘‘‘width=400,height=400‘‘‘‘)"

/body

/html

13.如何让我的页面出现一个会讲话的小人?Merlin

HTML 代码片段如下:

HTML

HEAD

TITLE默林/TITLE

META http-equiv=Content-Type content="text/html; charset=gb2312"

/HEAD

BODY

pOBJECT id=sims classid=CLSID:D45FD31B-5C6E-11D1-9EC1-00C04FD7081F

/OBJECT

SCRIPT

var MerlinID;

var MerlinACS;

sims.Connected = true;

MerlinLoaded = LoadLocalAgent(MerlinID, MerlinACS);

Merlin = sims.Characters.Character(MerlinID);

Merlin.Show();

Merlin.Play("Surprised");

Merlin.Speak("大家好");

Merlin.Play("GestureLeft");

Merlin.Think("我是默林!");

Merlin.Play("Pleased");

Merlin.Think("可爱吗?");

Merlin.Play("GestureDown");

Merlin.Speak("哈哈!");

Merlin.Hide();

function LoadLocalAgent(CharID, CharACS){

LoadReq = sims.Characters.Load(CharID, CharACS);

return(true);

}

/SCRIPT

/p

p /p

p看此效果必须装有office2000!!!/p

/BODY

/HTML

14.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动

HTML 代码片段如下:

htmlhead

STYLE

body  {background-image:url(logo.gif);

background-repeat:no-repeat; background-position:center }

/STYLE

/head

body bgproperties="fixed"

/body

/html

[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

background-repeat:no-repeat; 是让背景图不占满整个页面

body bgproperties="fixed" 是拉动scroll时背景图不动

15.文本输入框什么属性能实现不可输入?

HTML 代码片段如下:

input type="text" name="textfield" disabled

或者

input type="text" name="textfield" readonly

16.如何禁止自己的页面在别人的框架里打开?

把以下代码加至你的head区

script

if (window.top!=self){

window.top.location=self.location

}

/script

17.如何实现首页全屏幕显示?

HTML 代码片段如下:

html

bodyscript language="B style="color:black;background-color:#A0FFFF"javascript/B"

var coolw=642

var coolh=400

var coolhuang=window.open("","coolhuang","width="+coolw+",height="+coolh+",

fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0")

window.close()

/script/body/html

18.如何监听一个窗口被关闭了?

HTML 代码片段如下:

body onunload="alert(‘‘‘‘你关闭了这个窗口‘‘‘‘)"

19.如何禁止Ctrl+N?

HTML 代码片段如下:

body onkeydown=return(!(event.keyCode==78event.ctrlKey))

如何把页面加入用户的收藏夹?

HTML 代码片段如下:

a href="B style="color:black;background-color:#A0FFFF"javascript/B:window.external.AddFavorite(‘‘‘‘‘‘‘‘,‘‘‘‘无忧脚本‘‘‘‘)"收藏无忧脚本/a

如何在我的'页面中加入背景音乐?

IE: bgsound src="*.mid" loop=infinite

NS:embed src="*.mid" autostart=true hidden=true loop=true

*.mid你的背景音乐的midi格式文件

关于页面转换效果

meta http-equiv="page-enter" content="revealTrans(Duration=4,Transition=23)"

meta http-equiv="page-exit" content="revealTrans(Duration=4,Transition=23)"

说明:Transition=23是随机效果,另可以选0-22任一数字固定某个效果

如何设定打开页面的大小

HTML 代码片段如下:

body onload="top.resizeTo(300,200);"!--(width,height)--

怎样双击滚屏,单击停止?

HTML 代码片段如下:

html

head

title新网页1/title

/head

body

script language"B style="color:black;background-color:#A0FFFF"javascript/B"

var currentpos,timer;

function initialize()

{

timer=setInterval("scrollwindow()",10);

}

function sc(){

clearInterval(timer);

}

function scrollwindow()

{

currentpos=document.body.scrollTop;

window.scroll(0,++currentpos);

if (currentpos != document.body.scrollTop)

sc();

}

document.onmousedown=sc

document.ondblclick=initialize

/script

pa/ppa/ppa/ppaa/ppaa/ppaa/p

paa/ppaa/ppaa/ppaa/ppaa/ppaa/p

paa/ppaa/ppaa/ppaa/ppaa/ppaa/p

paa/ppaa/ppaa/ppaa/ppa/p

/body

/html

如何让body中的文字不被选中?

HTML 代码片段如下:

body onselectstart="return false" aaa/body

如何让弹出的窗口不能关闭?

在新开的窗口中加入如下代码

body onunload=open(location.href)

/body

如何让浏览器在保存页面时保存失败?

HTML 代码片段如下:

NOSCRIPT

B style="color:black;background-color:#ffff66"IFRAME/B SRC="*.html"

/B style="color:black;background-color:#ffff66"IFRAME/B

/NOSCRIPT

表单中如何用图片按钮实现 reset?

html

head

script

function aaa(){

document.forms[0].reset()

}

/script

/head

body

form

textarea rows="2" name="S1" cols="20"/textarea

input type="submit" values="提交" name="B1"

image src="logo.gif" onclick=aaa()

/form

/body/html

进入网页时弹出的信息对话框

body onLoad="window.alert(‘‘‘‘欢迎光临本站‘‘‘‘)"

关闭窗口后弹出对话框

body onUnload="window.alert(‘‘‘‘谢谢你的光临!欢迎下次再来!‘‘‘‘)"

告别提示

body onUnload= alert("再见,感谢你的访问!")

右键菜单的制作

OBJECT id=menu type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"

PARAM name="Command" value="Related Topics,menu"

PARAM name="Item1" value="动易;"

PARAM name="Item2" value="搜狐;"

PARAM name="Item3" value="新浪;"

PARAM name="Item4" value="网易;"

PARAM name="Item5" value="互动学院;"

/OBJECT script if (document.all) document.body.onmousedown=new Function("if (event.button==2) menu.Click();") /script

下拉菜单

object id=HHCtrl type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" PARAM name="Command" value="Related Topics,Menu" PARAM name="Item1" value="aspease;" PARAM name="Item2" value="byhu;" PARAM name="Item3" value="lzz;" /object a href=javascript:HHCtrl.Click() title="下拉菜单"下拉菜单/a

;

常用的网页代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于现成的网页代码、常用的网页代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/22004.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载