java 注释 html_[Java教程]HTML条件注释与JavaScript条件注释

[Java教程]HTML条件注释与JavaScript条件注释

0

2013-10-08 17:00:08

HTML条件注释和javascript条件注释

条件注释主要是针对ie的不兼容性,通过条件注释实现以某种方式为ie编写代码,而按照另一种方式为其他浏览器编写代码。条件注释并不符合标准规范,但在处理不兼容性事非常有用。

HTML条件注释

html条件注释,经测试能被ie以外的浏览器识别,输出结果与预想一致。

This is normal HTML content,but IE will not display it because of

the comment above and the comment below.

This is normal content,displayed by all browsers.

javascript条件注释

Javascript条件注释只被ie中JavaScript解释器支持。

/*@cc_on

@if(@_jscript)

//This code is inside a JS comment but is executed in IE.

//This code is inside a conditional comment,which is also a

//regular Javascript comment.IE runs it but other browsers ignore it.

alert("You are using Internet Explorer");

@else*/

//This code is no longer inside a Javascript comment,but is still

//inside the IE conditional comment. This means that all browsers

//excepte IE will run this code.

alert("you are not using Internet Explorer");

/*@end

@*/

(以上案例参考Java权威指南Page 332)

本文网址:http://www.shaoqun.com/a/72037.html

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:admin@shaoqun.com。

JavaScript

0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值