1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.

Javascript and iframes.

Discussion in 'Hardware, Software & Troubleshooting' started by Angel_Mapper, Apr 17, 2013.

  1. Angel_Mapper

    Angel_Mapper Goooooooats

    Joined:
    Jun 17, 2001
    Messages:
    3,532
    Likes Received:
    3
    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: Apr 17, 2013
  2. Angel_Mapper

    Angel_Mapper Goooooooats

    Joined:
    Jun 17, 2001
    Messages:
    3,532
    Likes Received:
    3
    Aaaaaand of course I figure it out minutes after I post. The form name was screwed up and it wasn't finding the text box.
     

Share This Page