Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-11-2003, 06:37 PM   PM User | #1
zoobie
Senior Coder

 
Join Date: Jun 2002
Location: ColoRockyz
Posts: 1,642
Thanks: 1
Thanked 0 Times in 0 Posts
zoobie has a little shameless behaviour in the past
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( ! )">
zoobie is offline   Reply With Quote
Old 06-11-2003, 06:43 PM   PM User | #2
Choopernickel
Regular Coder

 
Join Date: Apr 2003
Location: Atlanta, GA
Posts: 487
Thanks: 0
Thanked 0 Times in 0 Posts
Choopernickel is an unknown quantity at this point
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..
Choopernickel is offline   Reply With Quote
Old 06-11-2003, 07:34 PM   PM User | #3
zoobie
Senior Coder

 
Join Date: Jun 2002
Location: ColoRockyz
Posts: 1,642
Thanks: 1
Thanked 0 Times in 0 Posts
zoobie has a little shameless behaviour in the past
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( ! )">
zoobie is offline   Reply With Quote
Old 06-11-2003, 07:51 PM   PM User | #4
Choopernickel
Regular Coder

 
Join Date: Apr 2003
Location: Atlanta, GA
Posts: 487
Thanks: 0
Thanked 0 Times in 0 Posts
Choopernickel is an unknown quantity at this point
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.]
Choopernickel is offline   Reply With Quote
Old 06-11-2003, 10:58 PM   PM User | #5
zoobie
Senior Coder

 
Join Date: Jun 2002
Location: ColoRockyz
Posts: 1,642
Thanks: 1
Thanked 0 Times in 0 Posts
zoobie has a little shameless behaviour in the past
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
__________________
Zoobie or not Zoobie...That is the problem.
<body onUnload="flush( ! )">

Last edited by zoobie; 06-11-2003 at 11:59 PM..
zoobie is offline   Reply With Quote
Old 06-12-2003, 01:32 AM   PM User | #6
JustAsking
Regular Coder

 
Join Date: Jun 2002
Location: -27° 28' 22" , 153° 1' 22"
Posts: 135
Thanks: 0
Thanked 0 Times in 0 Posts
JustAsking is an unknown quantity at this point
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
File Type: zip framepages.zip (866 Bytes, 143 views)
__________________
"Computers are considered female - As soon as you make a commitment to one, you find yourself spending half your paycheck on accessories for it."
JustAsking is offline   Reply With Quote
Old 06-12-2003, 02:23 AM   PM User | #7
zoobie
Senior Coder

 
Join Date: Jun 2002
Location: ColoRockyz
Posts: 1,642
Thanks: 1
Thanked 0 Times in 0 Posts
zoobie has a little shameless behaviour in the past
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( ! )">
zoobie is offline   Reply With Quote
Old 06-12-2003, 02:47 AM   PM User | #8
JustAsking
Regular Coder

 
Join Date: Jun 2002
Location: -27° 28' 22" , 153° 1' 22"
Posts: 135
Thanks: 0
Thanked 0 Times in 0 Posts
JustAsking is an unknown quantity at this point
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."
JustAsking is offline   Reply With Quote
Old 06-12-2003, 03:10 AM   PM User | #9
zoobie
Senior Coder

 
Join Date: Jun 2002
Location: ColoRockyz
Posts: 1,642
Thanks: 1
Thanked 0 Times in 0 Posts
zoobie has a little shameless behaviour in the past
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";
?
__________________
Zoobie or not Zoobie...That is the problem.
<body onUnload="flush( ! )">

Last edited by zoobie; 06-12-2003 at 07:30 AM..
zoobie is offline   Reply With Quote
Old 06-12-2003, 07:37 AM   PM User | #10
JustAsking
Regular Coder

 
Join Date: Jun 2002
Location: -27° 28' 22" , 153° 1' 22"
Posts: 135
Thanks: 0
Thanked 0 Times in 0 Posts
JustAsking is an unknown quantity at this point
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."
JustAsking is offline   Reply With Quote
Old 06-12-2003, 07:46 AM   PM User | #11
zoobie
Senior Coder

 
Join Date: Jun 2002
Location: ColoRockyz
Posts: 1,642
Thanks: 1
Thanked 0 Times in 0 Posts
zoobie has a little shameless behaviour in the past
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
__________________
Zoobie or not Zoobie...That is the problem.
<body onUnload="flush( ! )">

Last edited by zoobie; 06-12-2003 at 09:21 AM..
zoobie is offline   Reply With Quote
Old 06-12-2003, 02:10 PM   PM User | #12
Choopernickel
Regular Coder

 
Join Date: Apr 2003
Location: Atlanta, GA
Posts: 487
Thanks: 0
Thanked 0 Times in 0 Posts
Choopernickel is an unknown quantity at this point
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
File Type: zip framekeeper.zip (1.2 KB, 164 views)
Choopernickel is offline   Reply With Quote
Old 06-12-2003, 09:59 PM   PM User | #13
zoobie
Senior Coder

 
Join Date: Jun 2002
Location: ColoRockyz
Posts: 1,642
Thanks: 1
Thanked 0 Times in 0 Posts
zoobie has a little shameless behaviour in the past
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( ! )">
zoobie is offline   Reply With Quote
Old 06-12-2003, 10:06 PM   PM User | #14
Choopernickel
Regular Coder

 
Join Date: Apr 2003
Location: Atlanta, GA
Posts: 487
Thanks: 0
Thanked 0 Times in 0 Posts
Choopernickel is an unknown quantity at this point
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?
Choopernickel is offline   Reply With Quote
Old 06-12-2003, 10:33 PM   PM User | #15
zoobie
Senior Coder

 
Join Date: Jun 2002
Location: ColoRockyz
Posts: 1,642
Thanks: 1
Thanked 0 Times in 0 Posts
zoobie has a little shameless behaviour in the past
I already did...

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

newLoc = "index.html?"+location.foreclosure.php; doesn't work
__________________
Zoobie or not Zoobie...That is the problem.
<body onUnload="flush( ! )">

Last edited by zoobie; 06-13-2003 at 12:07 AM..
zoobie is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:19 PM.


Advertisement
Log in to turn off these ads.