JSNI中的$ doc.getElementById(“id”)和document.getElementById(“id”)之间的区别是什么 [英] Which is the difference between $doc.getElementById("id") and document.getElementById("id") in JSNI
问题描述
这个方法有什么区别(概念上)?
提前感谢
您的GWT应用程式的代码会在(隐藏)的iframe中运行,所以文档
引用iframe的文档(和窗口
iframe的浏览上下文)。 GWT因此初始化变量 $ doc
和 $ wnd
,让您轻松引用文档和浏览上下文(
请注意,连接人员决定如何加载已编译的代码,默认值为($) c $ c> std )和较新的 xsiframe
使用iframe,而不建议使用的 xs
在同一浏览环境中加载代码(所以 $ doc == document
和 $ wnd == window
)
I'm working in a native function inside a GWT application and I've tried this two methods: document.getElementById("id") returns null but $doc.getElementById() returns a valid element. Which is the difference (conceptually) between this methods? Thanks in advance.
The code of your GWT app runs in a (hidden) iframe, so document
references that iframe's document (and window
the iframe's browsing context). GWT thus initializes the variables $doc
and $wnd
to let you easily reference the document and browsing context (window) of the "host page" that loads the GWT app.
Note that linkers decide how the compiled code is loaded, the default one (std
) and the newer xsiframe
use iframes, whereas the deprecated xs
loads your code in the same browsing context (so $doc == document
and $wnd == window
)
这篇关于JSNI中的$ doc.getElementById(“id”)和document.getElementById(“id”)之间的区别是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!