469,350 Members | 1,829 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,350 developers. It's quick & easy.

Why my script is partly working?

Hello folks,

My script is as below:

parent.menu.location.reload(true);

parent.frames("menu").TreeView1.CollapseAll();
parent.frames("menu").TreeView1.SelectNodeById(id) ;
parent.frames("menu").TreeView1.Render();

The first line is to refresh the menu frame
The second to fourth lines are to highlight a tree node.

For some reason, the second to fourth line codes are not working, it
seems to me they can't co-exist with the first line code. I can keep
either part and it works fine, but once I put them together, first line
is working, I saw the frame will be refreshed, but nothing happen after
that (a node is supposed to be highlighted by the second-fourth line
codes)

Anyone has any idea?

Thanks.

May 18 '06 #1
3 1426
Ivo
"Raymond" schreef
My script is as below:

parent.menu.location.reload(true);

parent.frames("menu").TreeView1.CollapseAll();
parent.frames("menu").TreeView1.SelectNodeById(id) ;
parent.frames("menu").TreeView1.Render();

The first line is to refresh the menu frame
The second to fourth lines are to highlight a tree node.

For some reason, the second to fourth line codes are not working, it
seems to me they can't co-exist with the first line code. I can keep
either part and it works fine, but once I put them together, first line
is working, I saw the frame will be refreshed, but nothing happen after
that...


Presumably the page hasn't finished (re)loading when the second line is
called. Such things take some time. Try fiddling with window.setTimeout() or
put some code in the framed page that signals the parent when loading is
complete.
Also, creating a temporary variable to refer to parent.frames.menu or even
parent.frames.menu.TreeView1 seems like a good idea.
hth
ivo
http://4umi.com/web/javascript/
May 18 '06 #2
Thank you for your reply. Here is my new idea

Goal:

I need to create an onclick event for a button. When click the button:
1. run code to refresh the menu frame:
parent.menu.location.reload(true);
2. run code to highlight a node in the menu frame

How:

Code:
function syncNode(id)
{
parent.menu.location.reload(true);

parent.frames("menu").TreeView1.CollapseAll();
parent.frames("menu").TreeView1.SelectNodeById(id) ;
parent.frames("menu").TreeView1.Render();

return true;
}

It won't work. Because when reload() the page lost the value of id
I guess if I can declare a sort of session variable in the html page,
then:
1. Every time I load the page, the page will check the session
variable's value (How to do this in aspx HTML code?)
2. In the onclick event, run another method:

Code:
function set_currid()
{
1. assign a new value to the sesstion variable
2. parent.menu.location.reload(true);
}

I also need to run another function somewhere in the page's HTML code
to do the highlight:

Code:
function highlight(id)
{
parent.frames("menu").TreeView1.CollapseAll();
parent.frames("menu").TreeView1.SelectNodeById(id) ;
parent.frames("menu").TreeView1.Render();
}

By doing this, because the page will have a new session variable
everytime it starts, so the it will highlight the node I want, whose id
is passed by the button's click event.

But please help, although I think this is the right way to do, I don't
know much javascript, can someone tell me how to write the code in
javascript/ and how to run the javascript in a html page?

Thank you very much.

May 19 '06 #3
Raymond wrote:
function syncNode(id)
{
parent.menu.location.reload(true);

parent.frames("menu").TreeView1.CollapseAll();
parent.frames("menu").TreeView1.SelectNodeById(id) ;
parent.frames("menu").TreeView1.Render();
Window::frames is a collection, not a method:

parent.frames["menu"]...
return true;
}

It won't work.
<URL:http://jibbering.com/faq/>
Because when reload() the page lost the value of id


Unless syncNode() is declared in the same frame that is reloaded by that
code, it should not happen, and probably you did something else wrong.
PointedEars
--
There are two possibilities: Either we are alone in the
universe or we are not. Both are equally terrifying.
-- Arthur C. Clarke
May 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Tim Morrison | last post: by
1 post views Thread by Steve Richter | last post: by
7 posts views Thread by David Schwartz | last post: by
9 posts views Thread by Jerim79 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.