Javascript and iframes.

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Angel_Mapper

Goooooooats
Jun 17, 2001
3,532
3
38
Cape Suzette
www.angelmapper.com
Hoping someone here knows enough about Javascript to help out. I'm having problems with a Javascript function being called from an iframe.

Here's the parent page:

Code:
<html>
<head>
<script language="JavaScript">
<!--

function test(sendvalue)
{
	document.out0.value = sendvalue;
	alert(sendvalue);
}

//-->
</script>
</head>
<body>

<p><input type=text name=out0></p>
<p><iframe style="width:100%; height:100%" src="TestPage.htm">
</iframe></p>

</body>
</html>

And here's TestPage which is loaded in the iframe:

Code:
<html>
<head>
</head>
<body>

<form name=a>
<input type=button value="Test" onClick="top.test('GOATS');">
</form>

</body>
</html>

I can get the alert to pop up saying "GOATS" no problem, but the text field in the parent doesn't change. If I have a button on the parent it works fine, so I'm guessing I need to change the "document." part of that line, but "top." and "parent." don't work either. Does anyone know what I'm doing wrong?
 
Last edited: