Click to See Complete Forum and Search --> : A Challenge - Layer/Div Tag related
gendv
06-27-2006, 08:39 AM
ok, firstly, an outline.
(Coursware is being created in DW)
I create coursware, and the coursware i'm crearing now is HTML, JS etc, etc. It works via MSIE, and is fullscreen, so it does not appear to the client that it is infact MSIE.
Ok, so here's the challenge.
There are paragraphs that build up (in layers) via show/hide function, at the ned of a build-up, it navigates to the next screen that works in precisely the same way.
What I need to know is, If I press the "Back" button from the second screen, it navigates, obviously to the 1st screen, BUT now, I need ALL the layers to be visible when I navigate back.
Any Suggestions?
If the "Back" button is one you have created you could pass a value back to the first page.
In the first page you would have a function that checks for this value and thrn run a function to show all the layers.
Another option would be to use a cookie
gendv
06-28-2006, 12:40 AM
I like your Idea abt using a cookie. How exactly do I do that?
Just a couple of questions
Would you want a session cookie or a persistant cookie?
Would all the divs be shown on returning to the page or only those that have been shown?
gendv
06-28-2006, 03:42 AM
Just a couple of questions
Would you want a session cookie or a persistant cookie? What would you suggest?
Would all the divs be shown on returning to the page or only those that have been shown? All Divs and ones that have been shown will be the same thing. So, All?
I was going to do you an example using a session cookie which would be ideal for what you want but for some reason my IE is not expiring the cookie, I have to look into this further, but for now you could give this a try which does not need a cookie.
This assumes that 1 or more divs will definately be revealed before going to page 2.
On clicking the back link in page 2 a value is passed to page 1.
A function in page 1 checks for this value and if it is there will reveal all the divs. Notice that all the divs have the same name appended with an ordinal number.
The number of divs must also be put in the script at variable numberOfDivs
When I find out whats wrong with IE I will hopefully post the session cookie example
page1.htm
<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
<script type="text/javascript">
<!--
numberOfDivs=4
function chkDivStatus(){
if (location.search.length > 0){
isViewed = unescape(location.search.substring(1))
if(isViewed==1){
for(var i=0;i<numberOfDivs;i++){
showHide("div"+i)
}
}
}
}
function showHide(id){
if(document.getElementById(id).style.display=="none"){
document.getElementById(id).style.display="block"
}
else{
document.getElementById(id).style.display="none"
}
}
//-->
</script>
</HEAD>
<BODY onload="chkDivStatus()">
Using location.search show all divs
<P>
<a href="#null" onclick="showHide('div0')">Show Div 1</a><BR>
<div id="div0" style="width:300px;height:50px;background-color:#55aa55;display:none">Div 1</div>
<P><a href="#null" onclick="showHide('div1')">Show Div 2</a><BR>
<div id="div1" style="width:300px;height:50px;background-color:#aaaa55;display:none">Div 2</div>
<P><a href="#null" onclick="showHide('div2')">Show Div 3</a><BR>
<div id="div2" style="width:300px;height:50px;background-color:#aa5555;display:none">Div 3</div>
<P><a href="#null" onclick="showHide('div3')">Show Div 4</a><BR>
<div id="div3" style="width:300px;height:50px;background-color:#5555aa;display:none">Div 4</div>
<P><a href="page2.htm">Go To Page 2</a>
</BODY>
</HTML>
page2.htm
<a href="page1.htm?1">Back To Page 1</a>
gendv
06-29-2006, 12:35 AM
Thank you so much. I appreciate the effort.