gpt4 book ai didi

javascript - 如何通过 javascript 从 CSS 类获取样式属性 ime-mode?

转载 作者:行者123 更新时间:2023-11-28 06:31:26 30 4
gpt4 key购买 nike

我输入了 cssclass imeoff 之类的

.imeoff{ime-mode: disabled}

我想通过使用读取属性 ime-mode

style = window.getComputedStyle(element),
top = style.getPropertyValue('ime-mode');

但是上面的代码只能在 IE 和 Firefox 上运行,不能在 chrome 上运行。

你有什么建议吗?

最佳答案

你的代码没问题,我不认为 Chrome 将 ime-mode 识别为有效的 css 属性,检查这个 fiddle

function getTheStyle(styleName){
var elem = document.getElementById("elem-container");
var theCSSprop = window.getComputedStyle(elem,null).getPropertyValue(styleName);
alert( theCSSprop );
document.getElementById("output").innerHTML = theCSSprop;
}
getTheStyle( "height" ) ;
getTheStyle( "ime-mode" ) ;

您无法读取无效的属性because

Javascript only has access to the DOM, not the code. So no, there is no way to access a property from javascript that the browser itself does not support.

关于javascript - 如何通过 javascript 从 CSS 类获取样式属性 ime-mode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34942619/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com