473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Tree gets scrolled back to top upon refresh

I have an annoyîng problem with a javascript tree. When you scroll
down to the bottom of the tree and click to open a node the tree is
refreshed and scrolls back to the top, hiding the node. Is there a way
to prevent the page from being scrolled back to the top on every
refresh? Thank you for your help.
Jul 23 '05 #1
4 2068
Sergio Millich wrote:
I have an annoyîng problem with a javascript tree. When you scroll
down to the bottom of the tree and click to open a node the tree is
refreshed and scrolls back to the top, hiding the node. Is there a way
to prevent the page from being scrolled back to the top on every
refresh? Thank you for your help.


If you post a brief example, you may get an answer more quickly. I'm
not quite sure what you mean by a "javascript tree" - I presume you are
talking about collapsible, hierarchical menus - but I may be wrong.

Rob.
Jul 23 '05 #2
RobG <rg***@iinet.net.auau> wrote in message news:<ht*****************@news.optus.net.au>...
Sergio Millich wrote:
I have an annoyîng problem with a javascript tree. When you scroll
down to the bottom of the tree and click to open a node the tree is
refreshed and scrolls back to the top, hiding the node. Is there a way
to prevent the page from being scrolled back to the top on every
refresh? Thank you for your help.


If you post a brief example, you may get an answer more quickly. I'm
not quite sure what you mean by a "javascript tree" - I presume you are
talking about collapsible, hierarchical menus - but I may be wrong.

Rob.


Is is in fact a tree that could be used as a menu or to navigate
through folders in Explorer style, it is indeed collapsible. The main
point is that as it expands in the frame so it has to be scrollable.
The source code snippet wouldn't be meaningful because it is embedded
in JSPs, here's what I have in the page:
<script language="JavaScript">function
setTreeParamsAndGo7129984(action, nodeId)
{setFieldValue('cti_current_contexte', 'GC_LOISFED.');go('/envirolex'
+ action + '?requestURI=%2Fenvirolex%2Fui%2FEnvUiLoisFed.jsp% 23tree7129984&nodeId='
+ nodeId, false);}</script>
<a name="tree7129984"></a>
<span class="tree"><ul>
<li><a class="treeActuator"
href="javascript:setTreeParamsAndGo7129984('/fermerNoeud.do','242');"><span
class="treeNodeOpenCH">&nbsp;</a><a class="treeActuator"
title="Numéro: RS 101"
href="javascript:setTreeParamsAndGo7129984('/selectionnerNoeud.do','242');">CONSTITUTION
FEDERALE</a></span><span><a
href="http://www.admin.ch/ch/f/rs/101/index.html"> @ </a></span>
etc...
Pretty meaningless if you don't know what the functions do.
What interests me is how to control the scrolling part. Thank you for
your answers.

Sergio.
Jul 23 '05 #3
On 19 Oct 2004 03:30:59 -0700, Sergio Millich <mi******@iprolink.ch> wrote:

[snip]
<script language="JavaScript">
The language attribute has been deprecated for many years now in favour of
the (required) type attribute.

<script type="text/javascript">

[reformatted:] function setTreeParamsAndGo7129984(action, nodeId) {
setFieldValue('cti_current_contexte', 'GC_LOISFED.');
go('/envirolex'
+ action
+ '?requestURI=%2Fenvirolex%2Fui%2FEnvUiLoisFed.jsp% 23tree7129984&nodeId='
+ nodeId, false);
}
It would seem to me that the go function call reloads the page containing
the menu. That's why it scrolls.
<a name="tree7129984"></a>
Though this anchor does exist, it may be ignored as it is empty. It would
probably be better to give the target an id with that value.
<span class="tree"><ul>
This is invalid mark-up. A SPAN element, which is inline, cannot contain a
UL, which is block-level. You should validate your HTML
(<URL:http://validator.w3.org/>).

[snip]
<a class="treeActuator"
href="javascript: [...] ">


You might want to read the FAQ (<URL:http://jibbering.com/faq/>),
especially section 2.24.

[snip]

Hope that helps,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4
Sergio Millich wrote:
RobG <rg***@iinet.net.auau> wrote in message news:<ht*****************@news.optus.net.au>...
If you post a brief example, you may get an answer more quickly. I'm
not quite sure what you mean by a "javascript tree" - I presume you are
talking about collapsible, hierarchical menus - but I may be wrong.

Rob.

Is is in fact a tree that could be used as a menu or to navigate
through folders in Explorer style, it is indeed collapsible. The main
point is that as it expands in the frame so it has to be scrollable.
The source code snippet wouldn't be meaningful because it is embedded


[snip]
Pretty meaningless if you don't know what the functions do.
What interests me is how to control the scrolling part. Thank you for
your answers.

Sergio.
Here are some code posted recently that shows collapsible menus, is
this something like what you are trying to do? These are designed to
work whether the user has JavaScript enabled or not.

Just put some <a> tags into the ends of the branches to get working
menus - follow the bottom branch.

Rob.

<html>
<head>
<script type="text/javascript">
function mClick(n) {
while (n.nodeName != 'LI' && n.nodeName != 'UL') {
n = n.parentNode;
}
var n0 = n;
while (n.nodeName != 'UL') {
n = n.parentNode;
}
var o = n.childNodes;
for (var i=0; i<o.length; ++i) {
if (0[i] != n0) hideUL(o[i]);
}
for (var k=0; k<n0.childNodes.length; ++k) {
if (n0.childNodes[k].style) n0.childNodes[k].style.display='';
}
}
function hideUL(x) {
if (x.nodeName == 'UL') x.style.display='none';
for (var j=0; j<x.childNodes.length; ++j) {
hideUL(x.childNodes[j]);
}
}
function resetMenu() {
mClick(document.getElementById("menu0"));
}
</script>
</head>
<body>
<!-- Menus start here -->
<ul id="menu0">
<li><a href="#" onclick="mClick(this)">menu 0 Level 0</a>
<ul id="menu1">
<li><a href="#"
onclick="mClick(this)">menu 0 Level 0 Level 0</a>
<ul>
<li>menu 0 Level 0 Level 0 Level 0</li>
<li>menu 0 Level 0 Level 0 Level 1</li>
<li><a href="#"
onclick="resetMenu();
">menu 0 Level 0 Level 0 Level 2</a></li>
</ul
</li>

<li><a href="#"
onclick="mClick(this)">menu 0 Level 0 Level 1</a>
<ul>
<li>menu 0 Level 0 Level 1 Level 0</li>
<li>menu 0 Level 0 Level 1 Level 1</li>
<li>menu 0 Level 0 Level 1 Level 2</li>
</ul
</li>
</ul>
</li>
<li><a href="#" onclick="mClick(this)">menu 0 Level 1</a>
<ul>
<li><a href="#"
onclick="mClick(this)">menu 0 Level 1 Level 0</a>
<ul>
<li>menu 0 Level 1 Level 0 Level 0</li>
<li>menu 0 Level 1 Level 0 Level 1</li>
<li>menu 0 Level 1 Level 0 Level 2</li>
</ul
</li>
<li><a href="#"
onclick="mClick(this)">menu 0 Level 1 Level 1</a>
<ul>
<li><a
href="http://www.apple.com"Apple</a></li> <li><a
href="http://www.sun.com"Sun</li> <li><a
href="http://www.mozilla.org"Mozilla</li>

</ul
</li>
</ul>
</li>
</ul>
<script type="text/javascript">

resetMenu();
</script>

<!-- Menus end here -->

</body>
</html>
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: AD. | last post by:
Hi all, I was wondering if anyone had any insights for me. I'm helping out some of our developers with the style sheets for a web app. One thing they are trying to achieve is getting rid of...
12
by: pillepop2003 | last post by:
Hey! Can anyone give me a hint, how this problem is best implemented: I have a table of users (see below), where every user has one "superior user" (= parent node), this should be a fully...
4
by: Robin Tucker | last post by:
Hi, I'm currently implementing a database with a tree structure in a table. The nodes in the tree are stored as records with a column called "Parent". The root of the tree has a "NULL" parent....
1
by: Nick Warrington | last post by:
Hi all, I am having a small problem with a tree control I am playing with. I have created a custom tree view that displays nodes with a linktext control to the right of the nodes. When the...
5
by: Pavan | last post by:
My goal is to accomplish the tooltip functionality for all the neodes in a tree view and i have the following three Events in my C# application. Name of my TreeView Control (AITreeView) 1)...
89
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
4
by: shinichi81 | last post by:
Could anyone help me? After updating icon for a drive, for example C drive by specifying icon file at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\C\DefaultIcon,...
1
by: tclancey | last post by:
Hi. I have an app that uses a tree view control to list locations, when the tree is clicked the application searches for stock in locations and displays them in grid. It's an odd thing, when...
27
by: SSG001 | last post by:
User selects choclates code and qty to be produced is entered by the user depending upon the packing of choclates the table is shown where again the produced qty is divided betwwen packing. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.