Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Page back into frame

    If my iframe page was found on the internet search engine by itself, how would I put it back into the index page with the found page in the iframe?

    The below just points to my index...but I need the page found on the internet to be inserted also.

    <script>
    if (parent == self) location.replace("index.html");
    </script>

    I'm too rusty...Thanks
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #2
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This'd be a multi-part script, probably similar to what microsoft's website does.

    first, in each sub-page, I'd say
    PHP Code:
    if (parent == selflocation.replace("index.html?pg="+location.path); 
    then, in the frameset (index.html), put together a frame relocator which depends on whether there's a query string:
    PHP Code:
    if (location.search && location.search.length>0){
         
    newFrameSrc location.search.split("?&")[0];
         
    newFrameSrc.split("=");
         if (
    newFrameSrc[0] == "pg")
              
    document.frames.main.src newFrameSrc[1];

    Not sure how that'll do for you, but I think that's probably the road you'll be going down.

    [edit: whoops, can't just relocate.]
    Last edited by Choopernickel; 06-11-2003 at 06:46 PM.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Well, I think I'm going to need clarification of said script. For example, my frame's name on the index.html is 'sara'. One of my pages is named 'foreclosure.php'...Now...to get foreclosure.php inside 'sara' on the index.html

    An example would be great...

    Thanks
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #4
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    okay, change that line in the second piece from
    document.frames.main.src = newFrameSrc[1];
    to
    document.frames.sara.src = newFrameSrc[1];

    and paste the first bit of code into foreclosure.php (or create a new file and <script src> it.

    What's happening here is that from the first snippet, the script says, "If I'm the top frame, better put me inside the frameset. Plus, I'll have to tell the frameset who I am, so the frameset can find me." The location.path property contains anything after the .com/ in your URL. Appending it on to the URL in the query string (what follows the ?) creates a value to be held in the index.htm's location.search property, which is where the next piece of script comes in.

    Name-value pairs in a query string are separated by ampersands (and sometimes question marks find their ways in there), so what we want to do here is create an array (using .split()) out of this location.search variable, and claim its first member (index 0, [0] )as our variable. What we've got in that variable is now pg=foreclosure.php - we then split() it again based on the equals sign we see, which turns it into an array containing ["pg", "foreclosure.php"] as its contents. The page name is at index 1, so that's what we want to change the frame's source to.

    Hope that helps.

    [edited for tags. tags? sheesh.]

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Still not working...I think I'm mixing apples and oranges as first, I'm testing locally...then the net. All pages are in the same folder.


    Part 1

    if (parent == self) location.replace("index.html?pg="+location.file:///C:/My%20Documents/Pages/Jim/Florida/);


    Part 2

    if (location.search && location.search.length>0){
    newFrameSrc = location.search.split("?&")[0];
    newFrameSrc.split("=");
    if (newFrameSrc[0] == "pg","foreclosure.php")
    document.frames.sara.src = newFrameSrc[1];
    }


    Thanks
    Last edited by zoobie; 06-11-2003 at 11:59 PM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    -27° 28' 22" , 153° 1' 22"
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    zoobie,

    I have attached a zip file with two pages:

    1. index.html - this is the frameset and has an iframe called 'sara'. Includes a js function.

    2. foreclosure.php - framed page with a js function to load it into index.html

    This works for me, so have a look at it and change it around if you need to. Hope it works

    Cheers...
    Attached Files Attached Files
    "Computers are considered female - As soon as you make a commitment to one, you find yourself spending half your paycheck on accessories for it."

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Nope...Still not working...I'm testing on the net now...but even with that simple version, all I get is a blank white page...Yep...I added the onload events, too.

    Part 1 in frame page(s)
    <script>
    <!--
    function LoadFrame(){
    if (parent == self) window.location.href = "index.html?foreclosure.php";
    }
    //-->
    </script>
    </head>
    <body onload="LoadFrame();">


    Part 2 in index.html
    <script>
    <!--
    function setFrame() {
    if(location.search) {
    window.sara.location = location.search.substring(1);
    }
    }
    //-->
    </script>
    </head>
    <body onload="setFrame();">

    I type www.host.com/foreclosure.php in the addressbar and all I get is a blank white page...
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    -27° 28' 22" , 153° 1' 22"
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    zoobie, not sure, I tested what I did only my server and it worked. Perhaps you could supply the exact www address and I will have a look at that. Maybe worth a try I guess?
    "Computers are considered female - As soon as you make a commitment to one, you find yourself spending half your paycheck on accessories for it."

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Well, it's working locally in the same folder...but not on the web. Do I need to need to use a full URL like:
    if (parent == self) window.location.href = "www.site.com/index.html?foreclosure.php";
    ?
    Last edited by zoobie; 06-12-2003 at 07:30 AM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #10
    Regular Coder
    Join Date
    Jun 2002
    Location
    -27° 28' 22" , 153° 1' 22"
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I guess if all your files are in the same folder location then you can use, if (parent == self) window.location.href = "index.html?foreclosure.php";

    but if the files are in different folder locations then you would need to specifiy the folder location and the filename, e.g.

    if (parent == self) window.location.href = "http://www.site.com/index.html?foreclosure.php";

    Give it a go, see if it works.
    "Computers are considered female - As soon as you make a commitment to one, you find yourself spending half your paycheck on accessories for it."

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok...I finally got it to work...Thanks. I wasn't waiting for both pages to fully load. I made a faster way...

    This doesn't allow the first page to load:

    if (parent == self) location.replace("index.html?foreclosure.php");

    Now, if we could just get the index to load this page into the frame immediately instead of waiting for the whole index to load, it would be faster yet...


    function doit() {
    if(location.search) {
    window.sara.location = location.search.substring(1);
    }
    }
    </script>
    </head>
    <body onload="doit();">


    Suggestions?

    Thanks
    Last edited by zoobie; 06-12-2003 at 09:21 AM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #12
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    zoob, here's the answer (works on my machine, works through one of my servers), attached.

    extract it and run it. based on my original script and justasking's script (combined best of both)

    let us know how it works.
    Attached Files Attached Files

  • #13
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry man...but I've never been able to get your scripts to run.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #14
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    damn zoob that's a low blow

    uh... what else of my scripts have you tried? seriously, i ran this one just fine locally and through an http server.

    you even willing to give this one a shot?

  • #15
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I already did...

    newLoc = "index.html?"+location.pathname;

    newLoc = "index.html?"+location.foreclosure.php; doesn't work
    Last edited by zoobie; 06-13-2003 at 12:07 AM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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