iframe 位置内的 JQuery3 对话框

时间:2021-03-18 13:40:36

标签: jquery jquery-ui iframe modal-dialog position

我正在尝试在 iframe 中打开一个对话框。 当我将位置设置为:

   position: { my: 'center', at: 'center', of: window }

指的是 iframe 的窗口。 这需要我在 iframe 很长时滚动。 我尝试使用:

  position: {my: "center", at: "center", of: window.top}

但我收到此错误:

jquery.min.js:3 Uncaught TypeError: Cannot read property 'defaultView' of undefined
    at La (jquery.min.js:3)
    at Ma (jquery.min.js:3)
    at Function.css (jquery.min.js:3)
    at Object.get (jquery.min.js:3)
    at Function.css (jquery.min.js:3)
    at jquery.min.js:4
    at S (jquery.min.js:3)
    at jQuery.fn.init.r.fn.<computed> [as outerWidth] (jquery.min.js:4)
    at d (jquery-ui.custom.min.js:formatted:614)
    at jQuery.fn.init.e.fn.position (jquery-ui.custom.min.js:formatted:666)

1 个答案:

答案 0 :(得分:2)

您可以考虑以下几点:

position: { my: 'center', at: 'top', of: window }

请参阅:https://api.jqueryui.com/position/

at 部分可以使用水平和垂直元素。

<块引用>

定义目标元素上的哪个位置对齐定位元素:“水平垂直”对齐。有关可能值的完整详细信息,请参阅 my 选项。百分比偏移量是相对于目标元素的。

查看 my 定义时,它说:

<块引用>

定义要定位的元素上的哪个位置与目标元素对齐:“水平垂直”对齐。单个值(例如 "right" 将标准化为 "right center""top" 将标准化为 "center top"(遵循 CSS 约定)。可接受的水平值:"left""center""right"。可接受的垂直值:"top""center""bottom"。示例:"left top""center center"。每个维度还可以包含偏移量,以像素或百分比为单位,例如 "right+10 top-25%"。百分比偏移量相对于被定位的元素。

相关问题