Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
什么Javascript函数会打开HTML文件并指定其iFrame源_Javascript_Html_Iframe - Fatal编程技术网

什么Javascript函数会打开HTML文件并指定其iFrame源

什么Javascript函数会打开HTML文件并指定其iFrame源,javascript,html,iframe,Javascript,Html,Iframe,我有数百个html文件,它们是培训课程中的课程,它们通常被视为课程的一部分。我现在被要求允许用户自己查看课程,因此我想在一个单一的、通用的lessonWrapper.html文件中打开它们,该文件在lessonWrapper.html的iFrame中显示各个课程内容html文件,我们称它们为Lesson.html。通过这种方式,我可以将内容放在中心位置,并在iFrame的上方或下方添加任何导航元素,而不必触碰lesson.html,这一点很重要 为了清楚起见,用户浏览html页面中托管的Flex

我有数百个html文件,它们是培训课程中的课程,它们通常被视为课程的一部分。我现在被要求允许用户自己查看课程,因此我想在一个单一的、通用的lessonWrapper.html文件中打开它们,该文件在lessonWrapper.html的iFrame中显示各个课程内容html文件,我们称它们为Lesson.html。通过这种方式,我可以将内容放在中心位置,并在iFrame的上方或下方添加任何导航元素,而不必触碰lesson.html,这一点很重要

为了清楚起见,用户浏览html页面中托管的Flex swf文件中的课程列表,我们称之为browse.html。用户单击按钮,将调用以下ActionScript:

if (ExternalInterface.available) {

// Call the 'loadLesson' Javascript function.
ExternalInterface.call("loadLesson", "004.html");
}
这将调用browse.html中的JavaScript函数'loadLesson',并传递参数'004.html',该参数是我们希望在lessonWrapper.html的iFrame中显示的课程名称

browse.html中的JavaScript函数如下所示:

    <script type="text/javascript">

    function loadLesson(_path) {

    //alert("loadLesson called successfully.");

    var myWindow = window.open ("tdc/Lobjs/dev/lessonWrapper.html","window");
    var iframe = document.getElementsByTagName('iframe')[0];

    alert("iFrame name: " + iframe.name);

    myWindow.frames[0].src = "JavaScript:'004.html'";

    myWindow.frames['lessonIframe'].onload = function() {
    alert('Window loaded')


    }
    //alert("iFrame.name: " + myWindow.frames[0].name);
    //document.getElementById('lessonIframe').src = _path;
    }

    </script>
正如你所看到的,我在这里尝试了各种各样的方法,并注释掉了我之前尝试过的一些行。我只想打开lessonWrapper.html并显示我的lesson 004.html,我在名为“lessonframe”的iFrame中将其作为参数“_path”传递

也许我是完全错误的。我欢迎你的想法和明智的建议

问候


Chris

在访问文档DOM中的任何元素之前,您必须等待窗口完成对文档的解析。这似乎是合理的。当lessonWrapper.html完成加载后,我是否可以设置回调或侦听事件?