无法在 IE 9 中传递此运算符的值,而它在 IE7 和 IE8 中工作正常
Unable to pass value of this operator in IE 9 while it is working fine in IE7 and IE8
我无法使用此运算符将对象传递给 loadApp() 来使用div 标签的属性
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<script>
function loadApp(theItem)
{
_thePage = theItem.appname;
alert(_thePage);// displaying undefined value in IE 9 while it works in IE7 and IE8(../eisptool.html)
}
</script>
</head>
在正文中,我们有一个具有以下属性的div 标签:
<div class="treeItem" onclick="setGroup('graph');loadApp(this)" fex="GSAS" appname="../eisptool.html" show="domainView calculationRule target" hide="trigger">Summary Graph</div>
当我尝试使用div 标签的 appname 属性时,我得到未定义的值。
某些属性会自动转换为浏览器的属性,例如 .id
。 但是,自定义属性通常不会转换为属性,因此如果要在所有浏览器中读取自定义属性,则需要使用 .getAttribute()
读取它。
function loadApp(theItem) {
_thePage = theItem.getAttribute("appname");
alert(_thePage);
}
当然,您确实应该将HTML5规范用于自定义属性并使用data-
前缀,以便HTML中的自定义属性data-appname="../eisptool.html"
并且您将使用getAttribute("data-appname")
。
相关文章:
- Recaptcha在IE7和IE8中不起作用
- Google地图API(IE7 IE8)的堆栈溢出
- ie7和ie8中的JQuery/Javascript问题
- IE9中的有效输出,但IE7/IE8中的未定义输出
- Onclick无法在IE8和IE7中启用只读字段
- IE7/IE8 中的 Javascript JSON Date 解析返回 NaN
- 获取尾随逗号(在JavaScript中)在IE7 / IE8中工作
- Facebook评论小部件使页面在IE7 IE8中跳到底部
- 用于重定向的IE7/IE8 javascript下拉菜单不起作用
- Function Expected In IE7 & IE8
- 在IE7, IE8中首次加载时字体过大
- IE7,IE8使用ajax执行函数错误
- jquery访问IE7 IE8的动态元素
- Onclick事件有时不会触发(IE6/IE7/IE8)
- 当尝试使用JavaScript动态添加表元素时,innerHTML在IE7, IE8和IE9中不呈现
- Jquery Fancybox阴影不显示在IE7/IE8
- 无法在IE7/IE8中使用javascript创建cookie
- Jquery在滑块的ie6 ie7 ie8中返回无效的属性值
- jQuery.remove()上的IE7/IE8 Javascript错误
- 不能执行自由脚本中的代码- IE6 IE7 IE8 IE9