View Full Version : Trouble targeting a frame

Feb 7th, 2003, 08:03 PM
I have been working with the following bit of code:

var location=("http://" + theURL);
this.location.href = location;

which is embedded in the bottom frame of an HTA document. I want the URL, however, to display in the top frame (I'll call it "viewer"). I have tried using top.location.href instead, but it still loads the entire page. I have also tried parent.location.href and parent.viewer.location.href. to no avail.

I even thought that perhaps the HTA extension might be thr problem and switched it to HTML but still no luck.

Any ideas?

Feb 7th, 2003, 08:09 PM
You need to specify the frame name like this:
parent.frame_name.location.href="some url"
Or if it is the first frame you could do this:
parent.frames[0].location.href="some URL"

Quiet Storm
Feb 7th, 2003, 08:50 PM
I think the var name 'location' would be a problem... maybe try:

var loc1=("http://" + theURL);
this.location.href = loc1;

Feb 7th, 2003, 09:17 PM
Thanks! A combination of the two did the trick!

Feb 8th, 2003, 01:20 AM
Ok, here's a new twist to my problem. The above changes work perfectly when I save and test the file as HTML. However, upon saving it as an .HTA file I receive the error message "parent.frames.0.location is null ir not an object" (however, in the code it was typed as parent.frames[0].location.href).

It is really imperative that this be saved as an HTA file, but I can't figure out how to get by this obstacle.