Computing.Net > Forums > Web Development > sequentially open windows in frame

sequentially open windows in frame

Reply to Message Icon

Original Message
Name: drsmartman
Date: April 1, 2004 at 17:54:37 Pacific
Subject: sequentially open windows in frame
OS: win xp/mac os x
CPU/Ram: na
Comment:

hi all,

asked a similar question before, but have a different
solution now. i have a form that i submit to a php
page for processing...great, works fine. second,
based on the content supplied (e.g. purchase for
prod 1,2 and 3) i need to hit an outside site to place
a cookie on my browser....then checkout. for each of
the products above, i need to hit a url. i do this in a
hidden frame......see below.

<script>
function xyz{

//hit each URL to buy three products
//each page needs to be accessed
//to place a shopping cart cookie
//from another site on the browser

parent.buyWindow.location='url1';
parent.buyWindow.location='url2';
parent.buyWindow.location='url3';

//open shopping cart for checkout with all products
parent.buyWindow.location='buyURL';
window.open('buyURL');

}

</script>

Okay, so this solution kinda works. That is, the
hidden frame does get a cookie to hit my browser,
but it only seems to work for one product. That is,
only one of the URLs is accessed in that list. Any idea
why? Also, that window.open() method isn't working
on Mac OS X/Safari.

Any help is appreciated. Thanks.


Report Offensive Message For Removal

Response Number 1
Name: SN
Date: April 2, 2004 at 07:49:31 Pacific
Subject: sequentially open windows in frame
Reply: (edit)

parent.buyWindow.location='url1';
parent.buyWindow.location='url2';
parent.buyWindow.location='url3';

This is probably going too fast to make the request to the server and get the cookie. url3 is the only one that will work.

You can try putting in some wait commands after each one, but that would be a bad idea. It would be too dependent on connection speed.

Secondly, maybe you could be very tricky with javascript and keep on setting the frame's onLoad event to a function that changes it to the next url. I played around with it and I think it's possible, but I decided to wait and see what you said before I spent too much time on it.

Thirdly, you can do what I mentioned in the last thread and have separate frames for each url. I still think this is the best idea, but apparently it didn't work with your particular setup.

later,
-SN


Report Offensive Follow Up For Removal

Response Number 2
Name: drsmartman
Date: April 2, 2004 at 08:41:30 Pacific
Subject: sequentially open windows in frame
Reply: (edit)

Hey SN-

No, I did use the frame idea....just a blank, hidden
frame that loades the pages to obtain the cookies.
You are right about why the pages won't load....just
to fast. I guess I was thinking that the pages would
just "wait" automatically. Anyway, I am working with
the "onLoad()" idea now....just working through the
quirks. I'll post back with the results.

I thought I could just do something like...

if(parent.buyWindow.location.onload){ loadpage }
if(parent.buyWindow.location.onload){ loadpage2 }

...would work, but it isn't. Getting close though.


Report Offensive Follow Up For Removal

Response Number 3
Name: drsmartman
Date: April 3, 2004 at 12:34:50 Pacific
Subject: sequentially open windows in frame
Reply: (edit)

I know this can be done via the function below...

<frame src="buy.html" name="buyWindow" onLoad="parent.mainWindow.goBuy()">

The only problem is that I would need the goBuy() function to handle an Array of URLS....so wouldn't calling the function and having that frame load a URL create onLoad() event to occur again...thus causing an infinite loop? If there was only a way to "check" on the status of onLoad() of that frame....

Ugh!

Thanks


Report Offensive Follow Up For Removal

Response Number 4
Name: SN
Date: April 3, 2004 at 21:03:20 Pacific
Subject: sequentially open windows in frame
Reply: (edit)

I ran into a similar problem, and there are a few workarounds (I think), but they are pretty dirty. My basic idea was to have the visible frame set the hidden frame's onload() event to a function. This event handler would call a function in the parent or visible frame that would tell it that a specific url has been handled. Then the parent frame would make the appropriate changes for the next Onload event to load the next url, etc. I haven't thought it out very thoroughly, as you can probably tell, but this is the approach I would take.

Maybe you didn't understand what I had in mind for the frame solution...I was talking about having a separate frame for each URL (ie 5 frames for 5 products). That would create some PHP overhead, but really cut down on the needed JS. Is this an option?

Good luck DrS
-SN


Report Offensive Follow Up For Removal

Response Number 5
Name: drsmartman
Date: April 7, 2004 at 14:57:53 Pacific
Subject: sequentially open windows in frame
Reply: (edit)

SN--

Yes, funny I read this after figuring out a solution. As
a good computing.net "asker" I posted some of my
answer below. The question and concept is a bit
confusing to explain, but I did get the desired results
(well, maybe not...see follow up).

---------------
<html>
<head>
<title>ASA Registration</title>

<script language="JavaScript">

var loadedPage="0";
var loc = new Array();
var messageShown="false";
var onlineBuy="false";

function openUrls() {

if(loadedPage<loc.length) {


parent.buyWindow.location=loc[loadedPage];
loadedPage++;
}

if(loadedPage==loc.length && loc.length>0 &&
loadedPage>0 && messageShown=="false" &&
onlineBuy=="true"){

alert("all items loaded into cart");

window.open("purchasepage.php");
messageShown="true";
}
}

</script>

</head>

<frameset rows="0,*">

<frame src="buy.html" name="buyWindow"
onLoad="parent.openUrls()" NORESIZE>
<frame src="main.php" name="mainWindow">

</frameset>

</html>
---------------


I had trouble with the concept of how to set the loc
variable (the page) while at the same time increment
a global variable. So, when the appropriate action
took place in the mainWindow, I reset the 'loc'
variable to an array of sites....triggered the
buyWindow to reload.....then buyWindow was in a
loop until all the sites were read because I used the
parent frame variable 'loadedPage' which held it's
incremented value everytime it was accessed.

Anyway, it works on the majority of browsers used
now. However, how would I go about making this
cross-browser functional? Any ideas?

Thanks for the help!


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: sequentially open windows in frame

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software