简体   繁体   English

从外部javascript文件中调用位于iframe中的javascript函数

[英]Call javascript function residing in iframe from external javascript file

我在iframe中打开了一个html。在那里定义了一个javaScript函数说getSomething()。现在在父页面中我有一个外部javaScript文件。是否可以从外部javaScript文件访问getSomething()?

As long as both URLs are from the same domain, you can do it. 只要两个URL来自同一域,就可以做到。 Try calling something similar to the following from the external script file: 尝试从外部脚本文件中调用类似于以下内容的内容:

document.getElementByID("ReferringiFrame").getSomething();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM