menus in html pages - separate navigation from content - javascript

When creating menus for html pages, there are a lot of libraries, frameworks and plugins (like mentioned here). However, having studied various options it seems to me that
the menu is a series of elements defined on one page which selectively are displayed/hidden
all content activated by menu items is contained on one and the same page - together with all menu definitions
This brings, in my opinion, two problems:
the (single) page tends towards "unmanageable" with growing size
a search on something contained on the "third page" will result in the "first page" to be opened, and for a user it may not be obvious that he/she has to click through the menu to find what he/she was looking for
So I am looking for something where menu and content is more separated, but still makes use of the styling features of a modern framework (jQuery(UI), dojo, whatever), maybe on the basis of a JSON definition that can be loaded into each separate page.

Making an answer as request. :)
The comments on your experience suggest that you ahve come across tab controls more than real navigation. Tab controls are designed to flip between content on the same page, hiding and showing content based on whcih tab is selected. This does have the drawbacks that you suggested of requiring all content to be on the same page (or to use ajax to load it).
Conversely a menu system will usually just be a way of formatting a bunch of links you give it, possibly with a hierarchical structure. Usually a menu system in the raw HTML will be an unordered list containing links and possibly other unordered lists. The exact format may vary depending on the menu system in use. The menu system will tell you to put classes on the top level or to run some javascript over a specific element.
In terms of generating this server side you are probably best off with either an include file or common server side code to generate the menus (to avoid having to maintain them individually in all the pages on your site).
Having said all that I have no specific reccomendations but I did come across http://www.1stwebdesigner.com/css/36-eye-catching-jquery-navigation-menus/ whcih was the top google hit for "jquery navigation menus" and has plenty of options to look at. Additionally the one in the question you linked looks like it is a "proper" menu system.

Unless you have a huge menu option list, a tree structured ul won't be so heavy. You can have that menu on a different container, and the content in other, so it is not so unmanageable.
In the other hand, deploy the menu in a different HTTP call in order to get JSON data, and render it, could be more unmanageable than before. First, you need two HTTP calls, considering that the browser will issue only two HTTP calls to the same domain at the same time, to get the menu you are preventing the browser to get something else, or viceversa. You have to account the HTTP overhead, and that the menu query will be issued after the html and probably JS has been downloaded.
IMHO I think that the best performance is obtained keeping the html menu in the page code, and render it with CSS.
You can try to build it yourself. In the page's ready event, download a json menu data from the server with jQuery, build the html, apply the style you want and add it to the page.

Related

Moving an HTML+javascript page to iFrame

I have an existing website composed of individual pages (each page is a different tool that requires some user input (ie forms), and each with it's own set of javascript functions to populate dropdown lists, etc on that page). Each of the tools is accessed from the main index.html.
Instead of each tool being its own "stand-alone" page that is invoked from index.html, I'd like each tool to be displayed in an iFrame instead on the main page. This way the main page remains static, while only updating the iframe with whatever tool the user selects. So say on the main index page, I have a 3 tools menu (collect logs, collect KPIs, collect status), along with an iFrame. If the user selects collect logs for example, the menu containing "collect logs" stays there, but the "collect logs" page is displayed in the iFrame.
My problem is that all the HTML content works fine, but none of the javascript code in the selected tool page works (ie none of the drop downs get populated since it's the javascript code in the page that does that by reading a file on the server).
Is there an easy way to port each tool page (html+javascript) to an iFrame without having to re-write tons of code (in my naivety I thought simply invoking the page inside an iFrame using target='' in the href would work)? Or is there a better method of accomplishing what I'm trying to do? Maybe iFrame isn't the solution.
Content in iframes remain autonomous from the wrapper app, so it makes sense that it's not working correctly. Other than building a listener for a click event associated with the div wrapped around the iframe, the iframe document isn't accessible if it points to a different origin. (See [same-origin policy]
(https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy))
To stay with simple html/css/js solution:
You can use a regular div to wrap each 'stand-alone' content and then just use whatever button/navigation target you have display that div and hide the previous by changing their css display style with the onClick event.
More invasive option:
You may want to consider using a more modular JS approach, like React JS, to build components vs pages and utilize React's structure to toggle components.
With react you can render each 'tool' when the user selects it . You would be able to utilize React component state as well to help in storing data and such for the life-cycle of the component.

Changing the contents of HTML page depending on options on navbar

I'm making an administrator portal for a band-website. The design is as follows:
There is a side navigation bar(on the left of the page), with things to be done (such as verify reservation requests, answer fanmails, modify band info, upload photographs to the gallery etc.). Clicking on these options should populate a form in the empty space on the right. I don't want to create a separate page for every one of them.
I have checked hell lot of websides for side navs, but i see they all redirect to links to different pages. If anybody could suggest me what all i should explore.
What you are asking about is called 'Single Page Application'. You need to use JavaScript for this. Best way is using JavaScript MVC frameworks like Angular, Ember, React etc.

Best approach to showing multiple html without reloading page

I have a "server" that serves up individual html pages for each associated item in the server. I've done a lot of looking around but I'm afraid I just don't know enough to ask the right question. How I'd like it to work is as follows:
Static Sidebar (boostrap simple-sidebar)
Ordered list of links to associated html docs
When the associated link is pressed to display that content in my main container field.
From what I've read some use iframe in the main html container and make the clicked link the active link.
Others use bootstrap modal, but modals no longer support remote content.
Any hints toward how to ask the right question would be great!

split aspx page into sections rendered in tabs that load on demand

what is the easiest most efficient - from a performance standpoint - way to program an aspx that will have sections in it rendered as tabs and preferably to be loaded on demand?
I have a certain entity that can be edited by different groups of users, each user group being able to edit certain parts of it. I am thinking of rendering the parts accessible to a group in a tab on the page and then controlling access/load of the tabs based on user rights.
i know a couple of javascript frameworks that address this specific type of requirements do exist, however i am a novice js programmer, i never used it for anything more than handling control events and doing very basic stuff so i do not know how fast i can pick up and use one of them.
You don't really need tabs for that, have it a single page and just load/display data relevant to current user group.
One way to do this (since you're using ASP.NET) is to use MultiView control and display relevant View control for the current user group.

Accessible javascript alternatives to select elements

I am developing some javascript code that will replace a standard select element with a javascript controlled dropdown menu which will redirect users to a particular page. The standard select element must work when JS is disabled
An example of what I want to achieve is here: www.play.com
What I have noticed with this site is that they simply position the select element behind the javascript alternative. This means that both controls are available to screen readers and keyboard users.
Does anyone have any experience of setting such functionality up and have any suggestions for the best methods to ensure accessibility?
Plain links would be your starting setup, as they work to take users to new pages without any additional scripting required.
You can put them in a container ul, and then use javascript in a 'progressive enhancement' way to turn the list into a dropdown (by re-writing the html) for the people who've got it turned on. This way, a user without javascript turned on will have no problems, and the majority of users will see your drop-down menu.
Even better, don't use a select menu for navigation. It's not really semantically correct, and requires more work to make it operable and robust.
Try something like the Suckerfish drop-down menus which are based on nested lists: http://www.htmldog.com/articles/suckerfish/ or if you want a bit of jQuery fun: http://users.tpg.com.au/j_birch/plugins/superfish/#sample1

Categories

Resources