Open Multiple Links

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
foxaz
Beginner
Beginner
Posts: 2
Joined: Tue Jun 29, 2004 6:17 am
Location: Phoenix, Arizona
Contact:

Open Multiple Links

Post by foxaz »

Is there a way to assign multiple links?

I am using two IFrames, and it works to use one link and assign the target.

The code for opening two new pages in the two IFrames is easy with a regular HTML link code.

<a class="home" style="cursor:pointer; cursor:hand;" onClick="window.frames['main'].location ='http://www.governor.state.az.us/global/student_main.asp'; window.frames['side'].location ='http://www.governor.state.az.us/global/ ... ;">Student Resources</a>

Is there a way to use your navigational system to achieve the same result?

The link to the site I am working on is: http://www.richardfox.com/paul/final/paul.asp

To see it in action, click on the Constituent Services link, and then back on the Home link.

I prefer to put the Home link in your navigational system if I can find a solution.

Thanks,

Richard Fox
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 Richard,

I wrote a function way back when for use with v3 and regular frames that should also work with v5 and iframes. Here's the function

Code: Select all

function loadMultiFrames()
{
  if (arguments.length > 0)
  {
    for (var i=0; i<arguments.length; i++)
    {
      params = arguments[i].split("=");
      if (params[0].length > 0 && params[1].length > 0) parent[params[0]].location = params[1];
    }
  }
}
Paste that function into the top of your menu_data.js file.

The loadMultiFrames() function will let you load any number of frames or iframes with a single menu item. I.e., you can load one frame, two frames, three frames, etc... as many as you like. The function takes a variable number of parameters, each separated from the next with a comma. Each parameter is a string specifying a frameName/URL combination. The parameter should be formatted as \"frameName=URL\" where frameName is the name of the frame whose content you want to change -- name as given in the <frameset> or <iframe> tag -- and URL is the URL you want to load into the specified frame. An equal sign (=) separates frameName and URL, with NO SPACES in the string (I didn't feel like eliminating white space). To include this function call in an aI() menu item, it is also best to use escaped double-quotes (\") around each frameName/URL string, like \"frameName=URL\" (otherwise, you'll get odd behavior in some browsers).

For exmaple, a menu item named "Go" that loads page1.htm into an iframe named "topframe", page2.htm into an iframe named "bottomframe", and page3.htm into an iframe named "sideframe" might look like:

Code: Select all

aI("text=Go;url=javascript:loadMultiFrames(\"topframe=page1.htm\", \"bottomframe=page2.htm\", \"sideframe=page3.htm\");");
(all on one line... no wrapping)

In your application, the Home menu item might look like this:

Code: Select all

aI("text=Home;url=javascript:loadMultiFrames(\"main=http://www.governor.state.az.us/global/student_main.asp\", \"side=http://www.governor.state.az.us/global/student_side.asp\");");
(all on one line... no wrapping)

You can place a space after the comma between frameName/URL pairs if you like, or not.

Hope that helps,

Kevin
grimjim
Beginner
Beginner
Posts: 2
Joined: Mon Sep 13, 2004 5:14 pm

error on page when i use this function (version 5)

Post by grimjim »

Hi Richard,


I'm wondering if you got this function to work.... I get an "error on page" message flashing up in the statusbar and nothing loads (IE5). I have also tried it in Firefox and nothing loads either....
The site is not currently online. I have followed the instructions exactly several times, and tried pasting your code directly into my menu_data.js file, changing only the frame names.....



Any help would be greatly apprecciated.

Cheers


Jim
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 Jim,

I posted a working demo for you. Dig around in the menu_data.js file and see if that helps you out.

Hope that helps,

Kevin
grimjim
Beginner
Beginner
Posts: 2
Joined: Mon Sep 13, 2004 5:14 pm

Thanks!

Post by grimjim »

Thanks very much for the swift reply & assistance....

Cheers

Jim
foxaz
Beginner
Beginner
Posts: 2
Joined: Tue Jun 29, 2004 6:17 am
Location: Phoenix, Arizona
Contact:

Thanks for your help!

Post by foxaz »

Sorry it has taken me so long to reply and thank you all for your help.

Believe it or not, I am still working on the site. Government!?

I was done the middle of June, and then our committee (yikes) decided on some more features they wanted.

So, I finally got around to working on the solution you provided.

Until the site goes live, it is at: http://www.governor.state.az.us/paul.htm

We should go live sometime in October.

Hopefully!!!!!!!
Post Reply