dynamic iframes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    dynamic iframes

    Hello everyone,

    I am building a page that has two iframes (xFrame1, and xFrame2) in it.

    Both the pages in the frames are the same and have like JavaScript function names within them.

    I want to call a function on the parent page that would call the like named function within the selected iframe by passing in a value in the function on the parent page.

    Here is my code on the parent page:
    Code:
    <html>
    	<head>
    		<title></title>
    		<script type="text/javascript">
    			function UpdateFrame(FrameId)
    			{
    				parent.('xFrame'+ FrameId).UpdatePage();
    			}
    		</script>
    	</head>
    	<body>
    		<label onclick="UpdateFrame(1);">Click Me to update frame 1</label>
    		<label onclick="UpdateFrame(2);">Click Me to update frame 2</label>
    		
    		<iframe id="xFrame1" src="xPage.htm"></iframe>
    		<iframe id="xFrame2" src="xPage.htm"></iframe>
    	</body>
    </html>

    Here is my code on the framed pages (xPage.htm):
    Code:
    <html>
    	<head>
    		<title></title>
    		<script type="text/javascript">
    			function UpdatePage() 
    			{
    				window.location='http://bytes.com'
    			}
    		</script>
    	</head>
    	<body>
    		Hello World
    	</body>
    </html>


    Can anyone help me out here?


    Thanks~
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    just try:

    [CODE=javascript]frames['xFrame' + FrameId].UpdatePage();[/CODE]
    in your parent page's function ...

    kind regards

    Comment

    • CroCrew
      Recognized Expert Contributor
      • Jan 2008
      • 564

      #3
      Thanks I will give it a try.

      Comment

      Working...