Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript problem with javascript:parent.frames

Status
Not open for further replies.

nesplb

Programmer
Jul 29, 2003
109
NO
Hi!

I'm quite new to Javascript and I have a problem.
I have a menu-framework that is generated from php that writes menu items dynamically from a Database.
My Website is a frameset based site with a left frame, a top frame and a main frame. The main frame is called "middleFrame". The menu is on the left frame. When I click on a link on the menu I want the link to open in the mainframe and I want the leftframe to stay as it is.

The syntax of adding a menuitem is like this:
Code:
palmtree.addItem("name of menuitem", name of the parent node, "url")

-So when I try to make a new node I do like this:
Code:
palmtree.addItem("Nodename", Nodeparent, "javascript:parent.frames['middleFrame'].location.href='main.php?a=11&mapp_fk=436'");

The node is added and it puts the output from 'main.php?a=11&mapp_fk=436' on the mainframe when I click the link, but it also destroys my left frame. My leftframe contains only the text 'main.php?a=11&mapp_fk=436' after I have clicked the link, so the menu and everything disappears...
What am i doing wrong?

In advance, thanks!

Greetings
Pål



Pål Nesteby

PDC-Tangen
Norway
 
Try:
Code:
palmtree.addItem("Nodename", Nodeparent, "javascript:parent.frames['middleFrame'].location.href='main.php?a=11&mapp_fk=436'[COLOR=red yellow];return false;[/color]");

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
Thanks for the tip mate, but I still get an error so the page doesnt load..

It says:

"Return statement outside of function"...

My expression is like this now:
Code:
palmtree.addItem("Nodename",Nodeparent,"javascript:parent.frames['middleFrame'].location.href='main.php?a=11&mapp_fk=436';return false;");

Thanks



Pål Nesteby

PDC-Tangen
Norway
 
Hi again!

I found that the menu class had a "target" property that the Interface hadn't implemented. When I implemented this in the interface I could set the target by passing it as a variable instead!:)

The function call is now:

Code:
palmtree.addItem("Nodename",Nodeparent,"main.php?a=11&mapp_fk=436","middleFrame");

Anyway, thanks for tip!:-)




Pål Nesteby

PDC-Tangen
Norway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top