[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: not sure of how to go about this



hello andy,

Andy Augustine wrote:
> 
> At 10:29 AM 3/5/96 -0800, apathy wrote:
> >function check(loc)
> >{
> >setTimeout("",1000);
> >(loc!="odyssee.net") ? findHome() : parent.right.history.back();
> >}
> 
> At a quick glance, this is not the proper use of setTimeout. . .
> I think you meant:[use second line as a parameter of setTimeout]
> setTimout() should not be used to pause a script, but instead to delay
> execution of a method/function.  Are you sure that the 'loc' var is a 
> string your passing in?

re: setTimout -- right you are. but from a cursory browsing of the NS documentation, what i've 
done could be a common error for novices such as myself. i just wish a more verbose and less 
klunky version of the docs would be published. Jason Manger is supposed to have a book called 
"Essential Java" coming out soon; supposedly, it's about 60% Java, 40% Javascript. i'm not sure 
of the ISBN, but would you have any clue as to the release date for this book? last i heard, it 
was supposed to be this month, but none of the local bookstores have heard of it.

as for "loc," it is a string i'm passing in. when check() is called, "loc" would be the URL, 
disguised as some property of the frame's contents ie: parent.right.hostname, 
parent.location.back(), or somesuch.

> Also, this isn't right:
> 
> >while (parent.right.history.hostname != "odyssee.net")  // problem line
> >  {
> >    delta -= 1;
> >  };
> 
> This will call an indefinate loop if it is true the first time because
> .hostname  never changes.
> 
> I think you'd want something like this:
> 
> if (parent.right.history.hostname == "odyssee.net") {
>   parent.history.back()
>   check()
>  }
> 
> This would be *syntactilcally* correct, but you're functions still have to
> modified to get what you're looking for.  If you want more help, give a holler.

hrm. i suppose it would be helpful to tell you what the purpose of the script is. i've 
set up a web site dedicated to getting me a job by showing off my writing and HTML 
skills. the potential employer goes through a series of pages describing my skills. there 
are a number of links to external sites that i've used as examples of well designed or 
poorly designed pages. there is a "tour" button in the header which will take the potential 
employer on a commented tour of my non-begging-for-a-job site. the potential employer clicks it, 
but then decides to use the "back" button on the bottom of the page (which should take the 
potential employer to the last page *on my site*). the function(s) which are called when said 
button is clicked must look through the history of the frame, locate the last frame contents 
which was on my site, and take the surfer back there. however, the function(s) should be able 
to handle the exception case: that there were no intervening external web sites before the 
surfer got to the first tour page. the sequence of events (wrt the attached HTML file) should be 
as such:

web surfer jumps to external site, which is loaded in the right hand frame.
web surfer decides, out of the blue, to take a tour of my other web site
web surfer arrives at beginning page of tour site, and hits the back button
check() is called to
call check to find out if the previous page was, in fact, hosted on odyssee.net .
if not, call findHome() to go look for the last page the surfer saw on odyssee.net, and send the 
surfer there.

so far, check(loc) seems to be okay. parent.right.history(-1) (which i will change to .back(), 
because it's more convenient) is passed into check via the loc parm. if the last frame's hostname 
property == odyssee.net, then load that page into the same frame. else, calle findHome to find 
the last page in the history with a hostname of odyssee.net .

findHome should ideally look recursively for a page with the appropriate property, but i was 
never good at recursion, thus the current implementation. i've rewritten the function as follows 
with an attempt at recursion, though (note that i haven't changed what was in the attached HTML 
file -- i just attached that file so you could look at the framework the functions should be 
implemented in):

var delta="-2" 			// i want to pass the value of delta as an integer; since
				// javascript is so loosely typed, i'm unsure of the syntax.
				// should the quotes be there???

function check(loc)
{
setTimeout("(loc!='odyssee.net')?findHome(delta):parent.right.history.back()",1000);
// the 1000 is there because i want to make sure that the browser has at least partially
// loaded the right URLs, so that there is no ambivalence of what the value of back would
// be
}

function findHome()
{
if (parent.right.hostname.history(delta)=="odyssee.net")  // okay, time to sort out a major
	parent.history.back();				  // headache. what's the proper way
else  						          // to determine the hostname property
  {						  	  // of the history(delta) property?
 
  delta-="-1"						  // more confusion as to the syntax
  check(parent.right.history(delta)			  // of decrementing delta by an integer
						          // amount. quotes or no quotes?
  }
}

dunno if this will run yet; am at a friend's place. check out the page, if you want, at 
http://www.odyssee.net/~apathy/showcase/testbed.html .

thnx in advance for your help; you will receive credit on my pages for this.
ju
Title: Julian's Showcase Pages: Tour

Tour My Site!

Welcome aboard Julian's Showcase Pages' Tour. You will see both my web coding skills and my writing skills in action. Comments will be provided in the left most window. If, at any time, you want to see the site index for Julian's Showcase Pages, simply click on the "Index" graphic in the header frame. To return to the comments, click on the "Comments" graphic in the left most frame.

Enjoy your ride!