javascript - 从 Iframe 触发 Jquery 动画

标签 javascript jquery html css iframe

我正在研究 this页面动画。我在每个页面元素中包含了 iframe,如下面的代码所示:

<div class="pt-page pt-page-3">3
        <button class="pt-trigger" data-animation="50" data-goto="-1">Go to next page</button>
        <iframe src="file:///E:/Tech%20Nidarshan/Events%20Page/index2.html" style="position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:150;" ></iframe>
    </div>
    <div class="pt-page pt-page-4">4
        <button class="pt-trigger" data-animation="50" data-goto="-1">Go to next page</button>
    </div>
    <div class="pt-page pt-page-5">5
        <button class="pt-trigger" data-animation="50" data-goto="-1">Go to next page</button>
    </div>

这里标签触发页面转换。我可以在 iframe 中触发转换吗?

最佳答案

假设动画是在您的 iframe 中定义的函数。要从外部调用它,您可以为您的 iframe 提供一个 name 属性(即 name="myIframe")并以这种方式调用该函数:

window.myIframe.myFunction();

注意:在 Chrome 中,由于同源策略规则,这可能不适用于本地文件。在服务器上,或者使用 Firefox,应该没有问题。

关于javascript - 从 Iframe 触发 Jquery 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25593597/

相关文章:

javascript - 又一个 'Uncaught TypeError: Cannot call method ' apply ' of undefined '

javascript - 数字总和返回 NaN

javascript - 如何获取html div中的数据值?

javascript - .click inside stop : function (event, ui) 运行 X 次(其中 X 是项目数)而不是只运行一次

javascript - 如何获取数组并在数据源中使用

jquery - RequireJS - 在上下文中隔离 jQuery 版本和插件

html - pos :relative & overflow-y:scroll 内的固定位置 div

javascript - 如何在 python 中模拟 onclick 事件?

javascript - 如何在两个div之间切换?

html - Bootstrap 良好对齐