从一个框架调用页面到另一个框架不会运行我的 jquery 函数

发布于 2024-12-14 02:14:37 字数 1771 浏览 7 评论 0原文

我有一个页面,上面有一个内容特定的菜单栏。该页面有一个 iframe,可将实际内容加载到其中,然后我在其上运行高度和宽度 jquery 函数以填充窗口的其余部分。该代码在所有主流浏览器中都可以正常工作。然而,这个菜单栏/内容页面被加载到框架中。在 Chrome、Opera 和 Safari 中它可以工作,但是在 Firefox 中它会将页面调用到“内容”框架中,然后不在 iframe 上运行我的函数。

外部jquery代码: resize.js

测试页面:test-main.html

在框架中查看它!: <一个href="http://www">http://www dot rodbikes.com - 左侧的链接“测试,忽略我”会将测试页面加载到框架中。 (我的编辑再次破坏了链接,抱歉)

我知道框架很恶心,店主想保留它们。我知道我的 html 代码无法正确验证,当我确实获取了这几页的代码进行验证(使用 HTML 4.01 框架集)时,我遇到了同样的问题。

更多信息

我编写了 2 个函数来调整 iframe 和包含它的 div 的大小,这样无论查看大小如何,它们都会填充整个浏览器窗口。它位于 head: 中,

   <script type="text/javascript">
    $(setheight);
    $(setwidth);
    </script>

它从外部 .js 文件调用它:

function setheight() {
$(document).ready(function() {
     $('#one') .css({'height': (($(window).height()) - 119)+'px'});

     $('#uno') .css({'height': (($(window).height()) - 119)+'px'});
});
}

function setwidth(){


if ($('frame[name=content]', parent).length) {  
     $('#uno') .css({'width': (($(window).width()) - 171)+'px'});

    }
     else {
        $('#uno') .css({'width': (($(window).width()) - 4)+'px'});
     }
}

我在 OSX firefox 中发现 iframe 的样式没有更新。当我将页面加载到框架中时,其高度和宽度正是浏览器使用的库存 iframe 高度/宽度。

我也有与上面相同的代码,但

$(window).resize(function()

添加了这样的代码,以便如果调整窗口大小,样式应该动态更新。 该函数被调用,

function move() {

并且对它的调用是主体中的第一件事:

<script type='text/javascript'>
$(move);
</script>

同样,当在框架中时,这不会在 Firefox 中发生。

I have a page that has a content specific menu bar on it. This page has an iframe that loads the actual content into it, which i then run a height and width jquery function on to fill the remainder of the window. The code works fine in all major browsers. However, this menubar/content page is loaded into a frame. In Chrome, Opera and Safari it works, however in Firefox it calls the page into the "content" frame, then doesn't run my function on the iframe.

external jquery code: resize.js

test page: test-main.html

see it in a frame!: http://www dot rodbikes.com - the link on the left, "test, ignore me" will load the test page into the frame. (my edit broke the links again, sorry)

I know frames are gross, the shop owner wants to keep them. I know my html code doesn't validate properly, when i did get the code for those few pages to validate (using HTML 4.01 Frameset) I had the same problem.

More Info:

I wrote 2 functions for sizing the iframe and the div that contains it so they will fill the complete browser window, no matter the viewing size. This lives in the head:

   <script type="text/javascript">
    $(setheight);
    $(setwidth);
    </script>

which calls this from an external .js file:

function setheight() {
$(document).ready(function() {
     $('#one') .css({'height': (($(window).height()) - 119)+'px'});

     $('#uno') .css({'height': (($(window).height()) - 119)+'px'});
});
}

function setwidth(){


if ($('frame[name=content]', parent).length) {  
     $('#uno') .css({'width': (($(window).width()) - 171)+'px'});

    }
     else {
        $('#uno') .css({'width': (($(window).width()) - 4)+'px'});
     }
}

What I'm finding in OSX firefox is the iframe not having its style updated. When I load the page into a frame its height and width are just whatever stock iframe height/width the browser uses.

I also have the same code as above, except with

$(window).resize(function()

added so that if the window is resized, the style should update dynamically.
That function is called

function move() {

and the call to it is the first thing in the body:

<script type='text/javascript'>
$(move);
</script>

Again, this isn't happening in firefox when in a frame.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文