Hi!
I'm wondering if there's an easy way to load a webpage while the navigation bar remains firmly in place (absolute static positioning).
I'm assuming this is why AJAX exists.
Basically, I've got 20 web pages but they all have the same navigation bar that is always on-screen, always in the same position. I don't want it going anywhere while the browser fetches and displays the targeted web page.
If there's a tutorial out there on how to do this, I'd love a link to it.
Many thanks in advance.
Have the navigation in a div at the top of the page (I'm assuming horizontal navigation; if it's vertical, float it to the left.)
Underneath that, put a div with nothing in it and give it an id. (div id="contents"></div>).
For each link in the navigation, prevent the default action and call an AJaX function that will "get" the associated document for that link.
<a href="javascript:void(0);" onclick="ajaxFunctionGet('index.cfm')">Home</a>
<a href="javascript:void(0);" onclick="ajaxFunctionGet('about.cfm')">About Us</a>
...
<a href="javascript:void(0);" onclick="ajaxFunctionGet('login.cfm')">Login</a>
Write a javascript function that uses AJaX to call the contents of that document. If you are using jQuery it might be something like:
function ajaxFunctionGet(doc){
$.get(doc,function(data){ document.getElementById("contents").innerHTML = data; });
}
This is way oversimplified, but you should get the idea.
^_^
I just thought of something to add.
On all the documents that will become the innerHTML of the div, remove the doctype declaration, head, and body tags. Just the content should be presented. This is assuming that the document that contains the navigation and div for content will already have these things.
^_^
Whatever number you care to use, it represents a whole lot of people worldwide.
Consider
Nancy O.
It's NOT the smartest way to do it. But if you must do something like that, what I've suggested will work.
Agreed.
if you really need to do it this way, the smarter option would be (shudder, cringe) FRAMES.
Not Frames but an inline frame (iFrame) on the index page would work. No JavaScript links required. Each nav link would simply need a target attribute pointing to the iFrame ID:
<a href="page1.html" target="iFrameID">Page 1</a>
<a href="page2.html" target="iFrameID">Page 2</a>
Nancy O.
North America
Europe, Middle East and Africa
Asia Pacific