Is it possible to set value as attribute to iframe in HTML? Or is there any other solution?
<iframe name="some name" src="url" value="some values"></iframe>
JS代码
我正在使用像
这样的JavaScript访问属性parent.window.frames[window.name].name;
我的名字得当,但没有得到。
if possible then how to access??
答案 0 :(得分:0)
window.frames[window.name]
引用window
中的iframe
对象,而不是主页上的iframe
元素。如果您需要从iframe内部引用属性集iframe
,您可以这样设置:
var value = window.frameElement.getAttribute('value');
如果iframe
value
是自定义属性,则它不会反映到value
属性。我建议你使用data-*
attributes而不是自定义属性。