IFRAME中的脚本不调用父文档中定义的特定函数? [英] Script in an IFRAME not calling particular function defined in the parent document?

查看:57
本文介绍了IFRAME中的脚本不调用父文档中定义的特定函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照以下答案中的说明操作后:


http://bytes.com/topic/javascript/answers/153274-script-iframe-can-not-call-functions -defined-parent-document



我可以让子窗口在父窗口中执行该功能。


该功能只是在子页面加载时弹出一个警告窗口。


我很容易将其修改为我的意图,即在子窗口时执行父函数点击。


使用正文标签:


< body onclick =" parent.FUNCTION NAME HERE()">


我首先改变触发函数的方法,一切顺利。然后我试着改变将触发哪个功能。 (基本上使用我希望在点击子窗口时发生的功能,而不是测试中的功能)。一旦我做了这个切换,没有任何反应。


使用的网站是:



http://tylerpanesar.ca/



我想要的是什么时候菜单栏打开,用户选择一个链接,菜单关闭并转到该链接。这已经发生了。但是,如果用户打开菜单栏然后改变它并继续当前打开的页面,则菜单保持打开状态。


子窗口具有相同的代码来调用父函数调用menu.hide函数,但它不起作用。


任何帮助都将不胜感激。

提前致谢,

Tyler

After following the instructions from the answer below:


http://bytes.com/topic/javascript/answers/153274-script-iframe-can-not-call-functions-defined-parent-document


I was able to have the child window perform the function in the parent window.

The function was to only have an alert window pop up as the child page was loading.

I easily modified this to my intention which was to have a parent function performed when the child window was clicked.

Using the body tag:

<body onclick="parent.FUNCTION NAME HERE()">

I first change the method in which the function would be triggered, all went well there. then I tried to change which function would be triggered. (Basically use the function I wanted to happen on click of the child window rather then the function from the test). Once I did this switch, nothing happens.

The site this is being used on is:


http://tylerpanesar.ca/


What I want is when the menu bar is opened, the user chooses a link and the menu closes and goes to that link. This already happens. However if the user opens the menu bar and then changes there mind and continues with the page the are currently on, the menu stays open.

The child window has the same code to call the parent function to call the menu.hide function, but it does not work.

Any help would be greatly appreciated.
Thanks in advance,
Tyler

推荐答案

所以...只是为了澄清任务......你想要当鼠标离开菜单时关闭菜单...或当用户点击它之外?


亲切的问候
so ... just to clarify the task ... you want the menu to be closed when the mouse moves out of the menu ... or when the user clicks outside of it?

kind regards


目前它隐藏了只有当您选择其中一个菜单项时,它才会隐藏当你点击你的页面时。如果你能弄清楚如何让它隐藏在鼠标移出上那将是更好的选择。


我尝试了这种方法但是我只能将它转换为切换。菜单上的鼠标移出。然而,当您将鼠标悬停在菜单项上时,此方法会产生恼人的闪烁(因为我正在切换打开的菜单命令)。如果我拥有它隐藏关于鼠标移出的菜单它会隐藏一旦你离开主按钮。观众甚至没有机会点击链接。或者至少那是我做的时候发生的事情。你可能有更好的方法来实现这个目标。


告诉它在点击时隐藏的脚本在jQuery函数中:

Currently it "hides" only when you choose one of the menu items, but it does not "hide" when you CLICK on your curent page. If you could figure out how to get it to "hide" on a "mouse out" that would be the better option.

I attempted this method however i could only get it to "toggle" the menu on "mouse out". This method does however create an annoying flicker when you hover of the menu items (as it is toggling the open menu command I guess). If I had it "hide" the menu on "mouse out" it would "hide" as soon as you moved off of the main button. The viewer doesn''t even have a chance to click a link. or at least that is what happens when I did it. You may have a better method to achieve this.

The script that tells it to hide on click is within a jQuery function:

展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号


没有检查你的代码......但基本的想法是将mouseout事件分配给扩展菜单...而不是菜单按钮...如果您要我查看代码,您应该在这里发布相关部分...


亲切的问候
didn''t check your code ... but the basic idea would be to assign the mouseout event to the expanded menu ... not to the menu button ... if you want me to check the code you should post the relevant parts here ...

kind regards


这篇关于IFRAME中的脚本不调用父文档中定义的特定函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆