window.top.nagivate howto?

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
User avatar
bdill
Beginner
Beginner
Posts: 6
Joined: Tue Jan 04, 2005 6:42 pm
Location: Nashville, TN
Contact:

window.top.nagivate howto?

Post by bdill »

Most of my site is single-paged (no frames), but I have one page that does use frames. It is a simple two frameset page with a top and a bottom frameset. The menu is in the top frame. When I click on a menu item, the top frame navigates to the appropriate page leaving the bottom frameset unchanged. My desired behavior is to jump out of the frames altogether and navigate to the desired URL outside of any frames.

Basically I want to do a window.top.navigate('myurl'); for each of the menu item url's. Since I'm just passing the url as a parameter to the Milonic framework, I don't know how to achieve this.
1) Can this be done?
2) If so, how :?:

Any help would be much appreciated.
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

If you want it to open a new window and keep the frames still available then you'd add the target=new; parameter in the aI string ... url=whatever;target=new; you can also put targetfeatures= to put in whatever features you want. For example

Code: Select all

targetfeatures=width=440 height=410 toolbar=no location=no directories=no status=no menubar=no scrollbars=no resizable=yes copyhistory=no;
If you want to have it just open the linked page in the same browser window but no longer in frames, then I think you would put this code in your call for the menu in that top frame:

Code: Select all

<script type="text/javascript" src="milonic_src.js"></script>
<script	type="text/javascript">
if(parent.frames.length)top.location=document.location;
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=mmenuns4.js><\/scr"+"ipt>");		
  else _d.write("<scr"+"ipt language=JavaScript src=mmenudom.js><\/scr"+"ipt>"); 
 </script>
<script type="text/javascript" src="menu_data.js"></script>	

Ruth
User avatar
bdill
Beginner
Beginner
Posts: 6
Joined: Tue Jan 04, 2005 6:42 pm
Location: Nashville, TN
Contact:

It worked but...

Post by bdill »

The later of the two is the behavior that I am looking for. The code you posted works, but it messes up my other javascript navigation. :(

In addition to the menu (which I want to navigate out of the frames) the header frameset page also has "< Previous" and "Next >" buttons. These buttons use client side script to change the url of the bottom frame.

My frames page has 2 frames called "header" and "main". The header frame page contains the menu as well as this snippet of code for the "Previous" and "Next" buttons:

Code: Select all

window.parent.frames.main.location.href = <someurl>;
When I modify the document.location (with your suggested code), this snippet of code breaks, displaying the error "window.parent.frames.main is null or not an object".

Once I set the top.location=document.location for the "header" frameset is there any way to get a reference to the "main" frameset?
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

I'm not a javascript/function person, so the only thing I can think is to put a link in the menu which will take you back to the main, however it would take you back to the beginning, and it wouldn't solve the problem of the break in the client side script. I will ask and see if there is someone who would know any other solution.

Do you have a url with this frameset so that we can see what's up?

Ruth
User avatar
bdill
Beginner
Beginner
Posts: 6
Joined: Tue Jan 04, 2005 6:42 pm
Location: Nashville, TN
Contact:

The URL

Post by bdill »

Certainly! My code is a tangled web of include files and such, so I stripped out a bunch of stuff and made just a few simple pages that mimic what I am doing.

Note, when clicking on the menu, only click on "RTM" -> Home. All other menu links are bogus.

http://leftandwrite.com/brian/frametest/frame.htm is my code before making any changes (addind your suggested code). The Previous/Next navigation works fine, but when navigating the menu, it navigates the top frame to the desired URL rather than jumping out of the frame.

http://leftandwrite.com/brian/frametest2/frame.htm is the same thing with your suggested code in place. The menu now navigates as desired by jumping out of the frames :P , but the Prev/Next button clicks are broken. :(

Again thanks for your help so far! :)
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,
Ok, we have reach the end of my road, and gone halfway down a strange highway :lol: I have posted and asked if someone could take a look because this is much higher than my level. It will probably take a day or so, but someone will look at it.

Ruth
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi bdill,

I think this is a case of "you can't have your cake and eat it too."

To summarize so far,
bdill wrote:My desired behavior is to jump out of the frames altogether and navigate to the desired URL outside of any frames.
Ruth's second suggestion achieved that: Selecting a menu item shows the url in the same browser window, and breaks free of the frames. That's the "having your cake" part.
bdill wrote:The later of the two is the behavior that I am looking for. The code you posted works, but it messes up my other javascript navigation... In addition to the menu (which I want to navigate out of the frames) the header frameset page also has "< Previous" and "Next >" buttons. These buttons use client side script to change the url of the bottom frame.
This is the "can't eat it too" part. Essentially, you achieve the first goal by breaking out of the frameset... the new url is presented free of frames. But, since the frameset no longer exists, once you're at the new url, there are no more frames for your "<< Prev" and "Next >>" functions to address.

Clicking the "<< Prev" or "Next >>" button activates a series of function calls, the last of which is a call to the navigatePage() function. The last line of the navigatePage() function is:

Code: Select all

window.parent.frames.main.location.href = href;
As you've noted, that line of code is where the failure occurs. It fails because there is no more frameset (the frames array no longer exists on the page). With no more frameset, the frame you had named "main" also no longer exists on the page. Hence, there is no object named window.parent.frames.main for your function to affect. In simple terms, once you break out of the frameset, there are no more frames for your nav functions to address. Sort of a Catch 22.

If your ultimate goal is to be able to use your "<< Prev" and "Next >>" scheme no matted whether frames are used or not, then you'll have to do some re-coding. For example, when the Prev or Next button is clicked, before you change the URL, you'll first have to test to see whether frames are currently in use or not.

Hope that made sense,

Kevin
User avatar
bdill
Beginner
Beginner
Posts: 6
Joined: Tue Jan 04, 2005 6:42 pm
Location: Nashville, TN
Contact:

Post by bdill »

Yes, that makes perfect sense. The only reason I'm using frames here is so that the user can quickly cycle the content in the bottom frame page without having to reload the top frame page each time. In order to achieve this, the top.location cannot be changed and the framesets should remain as they originally were.

On the other hand, one thing is constant: when navigating via the menu I ALWAYS want to do a window.top.navigate('myurl');

My hope (request?) is that there be a global flag that I can set to tell the Milonic menu to always do a window.top.navigate(url) when it navigates.

The benefit to me would be obvious, but it could also be used as an anti-hijacking tool. If someone hijacks your page by putting it into a frame on one of their pages, when the user clicks a menu, it jumps out of their frames and directly on to your site unencumbered by the hijacker's pages.

Is this a feasible request?
User avatar
bdill
Beginner
Beginner
Posts: 6
Joined: Tue Jan 04, 2005 6:42 pm
Location: Nashville, TN
Contact:

Follow up

Post by bdill »

Just following up, since I haven't seen a reply in a couple of weeks.

Would it be a feasible request to have a global Milonic variable to make it such that all url's are navigated as a window.top.navigate('url')?
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

I have no idea since this is beyond my level. I know I didn't get a notice that you'd even posted here again, so there may have been a problem. I'll ask if someone can check.

If it's not possible, I had an idea, but again this is beyond my level so it may be a dumb suggestion. I'm wondering if there is a way to write a function that reads when you break out of frames and disables that back/forward function and hides the buttons?

Ruth
User avatar
bdill
Beginner
Beginner
Posts: 6
Joined: Tue Jan 04, 2005 6:42 pm
Location: Nashville, TN
Contact:

Post by bdill »

In this case, the Prev, Next buttons are the most import aspect of the page - even more so than the menu. Currently our "workaround" is to not even include the Milonic menu on this page at all.

Just to give some context of what we are doing - our system is an MLS. The "users" are Real Estate agents looking for listings.

The user does a search and gets a result set displayed in a grid/table. Let's say 50 records were returned. Each row of the table has a link to the detail info for that record. Instead of having the user click the detail, view it, close it, go back to the list, click another link, repeat we have a "turn-the page" style navigation.

Let's say the user clicks on the 3rd record. The frames page (the page that I am having issues with) opens up and displays the detail of record 3 of 50. The detail record is basically a full page report for that record. The user then would typically page through the detail records (Prev / Next).

The desire for the frames here is for many reasons.
  • 1) The Prev/Next buttons don't scroll when the user scrolls down the detail report. The Prev/Next buttons are crucial b/c the users are literally browsing the records.
2) Reduced download. Unfortunately many of our users are on dialup, so we are trying to accomodate as much as feasible. By using frames, we don't have to reload the menu, the Prev/Next buttons or their javascript code. Granted, the Milonic menu eliminates alot of this since we only need 4 lines of code to include the Milonic menu.

3) Page flicker. I know this sounds trivial, and believe me I fought this one tooth and nail, but the users don't want the navigate buttons to flicker when the page back and forth through the detail records.

When the user is on the frames page, they have dug deep into detail. At that point it it wouldn't be too much of a strech to have the users click "Back to list" to get back to their result grid. At that point, the Milonic menu is available to them. It would just be "nice to have" the Milonic in the frames page and be able to jump out of the frames page.
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

I've sent the info on. I actually know what the MLS is and how it works [though the synopsis form which is available in many states to home buyers isn't in CA] But, I've seen it in action for agents. Hopefully there will be a response shortly, because I'm not sure just how involved trying to put something like that in the program would be, how many other things might have to be changed, if any, etc.

Ruth
Post Reply