I have 2 html files.
1.html will call 2.html from iframe.
<iframe src="2.html" > </iframe>
2.html defined 2 javascript functions.
function func1(a, b, c) {
for () {
.....
}
}
function func2() {
func1(a, b, c);
}
HTML
<body onload="func2()">
Now my question is, I have to merge these 2 html files to one html. 2.html must be executed inside the iframe.
I tried to do by,
<!DOCTYPE html>
<html>
<body>
<iframe id="foo" onload="myFunction()" /> </iframe>
<script>
function myFunction() {
var iframe = document.getElementById('foo'),
iframedoc = iframe.contentDocument || iframe.contentWindow.document;
iframedoc.body.innerHTML = func2();
}
</script>
</body>
</html>
But func2() is not called. Could anyone suggest the way to call javascript functions inside iframe?
Thanks in advance.