Given an HTML DOM ID, how to get an element's position relative to the window in JavaScript/JQuery?(给定HTML DOM ID,如何在JavaScript / JQuery中获取元素相对于窗口的位置?)
This is not the same as relative to the document nor offset parent since the element may be inside an iframe or some other elements.(这与相对于文档和偏移父项不同,因为该元素可能位于iframe或其他元素内。) I need to get the screen location of the element's rectangle (as in position and dimension) as it is currently being displayed.(我需要获取元素矩形的屏幕位置(如位置和尺寸),因为它当前正在显示。) Negative values are acceptable if the element is currently off-screen (have been scrolled off).(如果元素当前处于屏幕外(已滚动关闭),则可以接受负值。)This is for an iPad (WebKit / WebView) application.(这适用于iPad(WebKit / WebView)应用程序。)
Whenever the user taps on a special link in anUIWebView
, I am supposed to open a popover view that displays further information about the link.(每当用户点击UIWebView
的特殊链接时,我应该打开一个弹出视图,显示有关该链接的更多信息。) The popover view needs to display an arrow that points back to the part of the screen that invokes it.(弹出视图需要显示一个箭头,该箭头指向调用它的屏幕部分。)
ask by adib translate from so