从HTML IFRAME调用JS函数(两个Web资源) [英] Calling a JS function from HTML IFRAME (both web resources)

查看:129
本文介绍了从HTML IFRAME调用JS函数(两个Web资源)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上传了两个网络资源, a.HTML b.JS 。在HTML文档中,我有一个部分,其中执行脚本(并且它按预期工作)将加载上载到我的表单上的IFRAME中。

I've uploaded two web resources, a.HTML and b.JS. In the HTML document I have a section where a script is executed (and it works as supposed to) upload loading into the IFRAME on my form.

现在,因为代码的大小,我觉得有必要重构它,我想把我的HTML网络资源的脚本标签中的一些方法移出到一个单独的JS网络资源。

Now, because of the size of the code, I feel the need to refactor it and I'd like to move out some of the methods from the script tag of my HTML web resource to a separate JS web resource.

在第一步,我按如下方式设置了单独的JS Web资源。

At the first step I've set up the separate JS web resource as follows.

function test() { alert("Success."); }

从HTML文档中的脚本执行以下操作,得到错误 test 似乎不为该页面所知。

From the script inside the HTML document I execute the following, getting an error as test seems not to be known to the page.

alert("Get ready for test...");
test();
alert("Did it work?");

我已经将JS网络资源添加到表单并保存发布,当然。关于这个问题的信息很少令人惊讶。我找到了这些链接,但没有一个与我需要的完全匹配,也没有给我提示如何处理手头的问题。

I've added the JS web resource to the form and savepublished, of course. There's surprisingly little info on the subject out there. I've found those links but none of them matches exactly what I need and gives me no hint on how to approach the issue at hand.


  • 此链接类似于我想要实现的目标它是关于从JS调用JS 这两者都是网络资源。

  • 此链接与我想要的对角线相对我不知道如何通过从JS <​​/ em>调用 HTML来反转它,这两者都是网络资源。

  • This link resembles what I want to achieve but it's about calling JS from JS where both are web resources.
  • This link is diagonally opposite to what I want but I don't know how to reverse it from calling HTML from JS whre both are web resources.

我应该纠正什么?

推荐答案

检查以下假设:


  • 保存网络资源?

  • 发布所有更改?

  • 将资源添加到reg中的框架arded entity?

  • 将函数命名为 hazaa

  • 调用正确的名称,即 parent。 window.test()

  • save the web resource?
  • publish all changes?
  • add the resource to the frame in the regarded entity?
  • name the function hazaa
  • call the correct name, i.e. parent.window.test()?

如果所有以上,做三件事。

If yes to all of the above, do three things.


  1. 联系Microsoft。你刚刚发现了一个严重的错误。

  2. 当心。 很快就会成为猪。

  3. 买一件外套。它会变得更冷。

  1. Contact Microsoft. You've just found a serious bug.
  2. Watch out. There will be pigs flying very soon.
  3. Get a coat. It's about to get much colder.

(我认为你肯定错过了什么在我提供的列表中,你不需要联系微软,猪不会开始飞行,地狱也不会冻结。)

(By that, I mean that you surely have missed on something in the list I've provided and that you need not to contact Microsoft, pigs won't start to fly and the hell won't freeze over.)

这篇关于从HTML IFRAME调用JS函数(两个Web资源)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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