Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Thanked 0 Times in 0 Posts

    Unhappy Controlling Frames Containing External Pages

    I have an index.html that sets up 3 Frames. They are called FrameTop, FrameA and FrameB. See pic below. In FrameTop the user can type in a url into a textbox with id="urlINPUT". When user clicks LOADA it loads that url into FrameA. User can then browse web in FrameA, clicking links etc and going to new pages. The second button LOADB is designed to determine the current location/url of the page displayed in FrameA and load that into FrameB. So far when I write the javascript in FrameTop LOADA works but LOADB loads the FrameTop into FrameB! [error!]

    If someone can please help me with this problem it would be much appreciated. This work is going towards a free website idea.

    I suspect my error lies in use of parent/self in the parent.frame.location.

    Here is my page layout.

    <frameset rows="5%,*">
    <frame name="FrameTop" src="frame_top.html" />
    <frameset cols="50%,50%">
    <frame name="FrameA" id="FrameA" src="frame_a.html" />
    <frame name="FrameB" id="FrameB" src="frame_b.html" />

    <SCRIPT language="JavaScript">

    function loadURLintoA() /*gets the url typed in by user and loads it into Frame A. This works fine*/
    var urlrequest= "http://"+document.getElementById('urlINPUT').value;
    parent.FrameA.location.href = urlrequest; /*sets FrameA location to url that user enters in frametop input*/



    <SCRIPT language="JavaScript">

    function loadAintoB() /*I WANT this to get the url of the website loaded in frame A and load it into frame B*/
    var urlofA = parent.FrameA.location;
    parent.FrameB.location = urlofA; /*this is supposed to get the url of FrameA and load it into FrameB*/



    <body bgcolor="#848484">
    http://<input type="text" name="urlINPUT" value="" id="urlINPUT" size="10">
    <input type="button" name="loadAbutton" id="loadAbutton" value="LOAD A" onclick="loadURLintoA()">
    <input type="button" name="loadBbutton" id="loadBbutton" value="LOAD B" onclick="loadAintoB()">


    What happens when I run index.html
    index.html loads the index correctly and displays FrameTop, FrameA and FrameB. The load A button also works correctly BUT when I click LoadB it loads FrameTop into FrameB! This happens when no page is loaded into FrameA AND when an external page in loaded in.

    Please help, I would be very greatfull if you could point out my mistake.

  2. #2
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Bucharest, ROMANIA
    Thanked 379 Times in 375 Posts
    Controlling Frames Containing External Pages
    You can't. Cross domain JavaScript relationships are not allowed due to obvious security reasons, thus you can not control a document from another domain loaded in a frame/iframe on your domain.
    Offshore programming


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts