Forum Moderators: open

Message Too Old, No Replies

frames['frame1'].document.createElement("IFRAME");

how?

         

Stuperfied

9:51 am on May 16, 2006 (gmt 0)

10+ Year Member



How can I get this to work?

<HTML>

<HEAD>
<TITLE>Frames Values</TITLE>

<script type="text/javascript" language="javascript">
function tellerror(){
alert('An error has occurred!') ;
return true ;
}
window.onerror=tellerror

function initialize() {
frames['frame1'].location.href = "whatever.htm";
alert('Load Finished') ;
}

function insertframe() {
var testFrame = frames['frame1'].document.createElement("IFRAME");
testFrame.id = "testFrame";
testFrame.src = "http://www.google.com";
frames['frame1'].document.body.appendChild(testFrame);
}
</script>

<meta http-equiv=refresh content="59; url=<?php $_SERVER['PHP_SELF'];?>">
</HEAD>

<body onload="initialize()">
<p>this is here.</p>
<input type=button value="insert" onClick="insertframe();">
<iframe id="frame1" width="100%" height="90%" name="frame1">
</body>

</html>

Stuperfied

1:10 pm on May 16, 2006 (gmt 0)

10+ Year Member



I should add that whatever.htm is a remote page.

jshanman

1:04 pm on May 17, 2006 (gmt 0)

10+ Year Member



You have no access to the DOM inside a remote site displayed in the frame. The site in the frame has no access to the parent DOM either, except to change (not read) the document.location.href .

This is done for security reasons.

- JS

Stuperfied

1:32 am on May 18, 2006 (gmt 0)

10+ Year Member



Can I somehow save a copy of the frames page to my server everytime it loads and then write to the copy?

whoisgregg

12:08 pm on May 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could set up a proxy script on your server to do that, but that is beyond the scope of javascript.

Basically you call /local_proxy.php?uri=htp://remotesite.com/whatever

The local_proxy.php script does just a few things: It fetches the remote url, writes the result into a database, then outputs the result. Depending on what you are proxying, the source site may be quite curious as to what you are doing and storing a local copy may make them unhappy.