在 CKEDitor 中最大化/调整对话框窗口大小
我需要以编程方式最大化/调整 CKEditor IFrame 对话框的大小(即带有“确定”和“取消”按钮的 CKEditor 对话框,以及其余的 iframe)。我需要对话框保持在屏幕中央。
我只能看到调整窗口大小和重新定位窗口的函数,但要使用这些函数,我必须首先计算窗口尺寸才能将其重新居中。由于多种原因,这是愚蠢的,API 应该完全处理这个问题。
是否有官方 API 函数可以执行此操作,或者有安全的解决方法?
我可以使用 JQuery,但真的很想为此使用本机函数。
I need to programmatically maximize / resize a CKEditor IFrame dialog (i.e. a CKEditor dialog with an "ok" and "cancel" button, and an iframe in it for the rest). I would need the dialog to stay centered on the screen.
I can see only functions to resize and re-position the window, but to use those, I'd have to calculate the window dimensions first to re-center it. This is stupid for a number of reasons, the API should handle that completely.
Is there an official API function to do this, or a safe workaround?
I can use JQuery but would really like to use native functions for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你同时调整大小和重新定位,那么执行一个功能并不难:(
它是伪 JavaScript,因为我没有时间完善它,所以基本上是想法)
然后任何时候你都可以调用
dialogResizeCentered(d,600,400);
或者?
或者,如果您希望对话框保持居中,我确信有类似
window.onResize
事件来调用此函数。我希望我理解正确:)
If you have both resize AND re-position, it can't be that hard do one function:
(it's pseudo javascript, since i don't have time to polish it, so basically idea)
and then anytime you can just call
dialogResizeCentered(d,600,400);
or?
Or if you want your dialog to stay centered, i'm sure there is something like
window.onResize
event to call this function.I hope I understand correctly :)
我自己使用 CKEditor,但选择使用 jquery 的 UI 对话框作为我的自定义对话框,因为它开箱即用更灵活且功能丰富,可在以下位置找到:
http://docs.jquery.com/UI/Dialog
但如果您更喜欢使用自定义 CKEditor 对话框,那么 jQuery 的position():
http://api.jquery.com/position/
height()、width() 和 offset() 是对于确定对话框的大小和位置非常有用:
http://api.jquery。 com/category/manipulation/style-properties/
I'm using CKEditor myself but have opted to use jquery's UI dialog for my custom dialogs as it is a lot more flexible and feature-rich out of the box, it's available at:
http://docs.jquery.com/UI/Dialog
But if you prefer on using a custom CKEditor dialog then jQuery's position():
http://api.jquery.com/position/
height(), width() and offset() are invaluable in determining the size and position of the dialog:
http://api.jquery.com/category/manipulation/style-properties/