473,394 Members | 1,702 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,394 software developers and data experts.

Using Java Script to create DHTML Pages

I have the following Script in my web page reduce to two pages.

<script>
function details()
{
document.getElementById('details').style.visibilit y='visible';
document.getElementById('capabilities').style.visi bility='hidden';
}
function capabilities()
{
document.getElementById('details').style.visibilit y='hidden';
document.getElementById('capabilities').style.visi bility='visible';
}
</script>

With the following HTML code..

<table id="Menu" border="1" width="100%">
<tr>
<td><a href="#" onclick="details()">Details</a></td>
<td><a href="#" onclick="capabilities()">Capabilities</a></td>
</tr>
</table>

<div id="details" style="position:absolute; visibility:visible;">
<table border="0"><caption>DETAILS</caption>
<tr><td>Name:</td><td>Enter name</td></tr>
<tr><td>Email:</td><td><a
href="mailto:an*****@anydomain.com">EmailName</a></td></tr>
<tr><td>D.O.B:</td><td>Date of Birth</td></tr>
</table>
</div>

<div id="capabilities" style="position:absolute; visibility:hidden;">
<table border ="0"><caption>CAPABILITIES</caption>
<tr><td>Java Script</td><tr>
<tr><td>Java Script</td><tr>
<tr><td>Langauges</td><tr>
</table>
</div>

What I am trying to do is create a CV where you turn the pages without
reloading the web page. I have successfully done this using the code
above but the links don't work in Internet Explorer until I have gone
through all the pages. Netscape and Opera Works Fine!

The above consists of two pages for convience but my final site will
be approx 6 to 7 pages long.

Can anybody help get the links working on loading up 1st time without
having to go through all the pages or is there a bug with IE?

Many Thanks

Dafydd
Jul 20 '05 #1
14 1847
da*************@ntlworld.com (Dafydd) writes:
I have the following Script in my web page reduce to two pages.
Your HTML doesn't validate.
<td><a href="#" onclick="details()">Details</a></td>
When I got to here, I guessed that the problem is that the page
reloads when you click on the link. To avoid that, at least
add ";return false;" to the onclick attribute value.

The problem is that you are using a link (<a href=...>) for something
that isn't linking to anything. That is not the best design. You
should use a button, that is what they are there for: click for an
effect, whereas links are meant to move you to a new resource.

The misuse of a link becomes visible because you have no relevant
information to put in the href. So you put some dummy information
there, and because you don't return false from the handler, that
dummy information is used.

What you could do was to write
<a href="#details" onclick="details()">Details</a>
Then clicking would both make the details visible, and move the
screen to the element with id="details". Then the link actually
makes sense.

(Now, let's see if my guess is correct :)
What I am trying to do is create a CV where you turn the pages without
reloading the web page. I have successfully done this using the code
above but the links don't work in Internet Explorer until I have gone
through all the pages.
Hmm, no, that was not the problem I expected. I think. Damn! :)

The link that "don't work" (not very precise description of the
problem) in the example is the e-mail link, correct?

It seems like the later (in the document) divs are overlaying it, even
while hidden, so you can't click the link. One thing that works for me
is to set the z-index of the first pane to 1. It only works for that
one, though.

Your code design doesn't scale very well. If you had ten panes, you
would have ten functions with ten lines each, i.e., code size
quadratic in the number of panes. That can be done shorter:
---
<script type="text/javascript">
var currentPane;
function setVisible(paneId) {
if (currentPane) {
currentPane.style.visibility = "hidden";
currentPane.style.zIndex = "";
}
currentPane = document.getElementById(paneId);
currentPane.style.visibility = "visible";
currentPane.style.zIndex = "1";
}
</script>
---
and then make the links as:
---
<a href="#details" onclick="setVisible('details');return false;">
---
and initialize the currentPane when the page has loaded:
---
<body onload="setVisible('details')">
...
---
(code not tested)

You still have the problem, that if Javascript is disabled, a lot of
your page will not be accessible.
Can anybody help get the links working on loading up 1st time without
having to go through all the pages or is there a bug with IE?


Yes and yes (I hope this works, and it definitly looks like a bug).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Dafydd wrote:
What I am trying to do is create a CV where you turn the pages without
reloading the web page. I have successfully done this using the code
above but the links don't work in Internet Explorer until I have gone
through all the pages. Netscape and Opera Works Fine!
.....
Can anybody help get the links working on loading up 1st time without
having to go through all the pages or is there a bug with IE?


As Lasse has pointed out, you should assign a z-index and to fix your
problem quikly, assigning it to the first div only will be sufficient:

<div id="details" style="position:absolute;visibility:visible;z-index:+1">

This way, all following divs will automatically get this div's z-index + 1.
JW

Jul 20 '05 #3
"Janwillem Borleffs" <jw@jwscripts.com> writes:
As Lasse has pointed out, you should assign a z-index and to fix your
problem quikly, assigning it to the first div only will be sufficient: <div id="details" style="position:absolute;visibility:visible;z-index:+1">

This way, all following divs will automatically get this div's z-index + 1.


Nope. Setting the z-index of this div does nothing for the following
divs (the value "+1" is equivalent to "1").

If you have three panes, just setting z-index on "details" won't
work. Switching to the second pane, you will see that its links still
doesn't work, because they are being "overlayed" by the third pane.

That is why I made sure to set the z-index of each element when it
was displayed.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
Lasse Reichstein Nielsen wrote:
Nope. Setting the z-index of this div does nothing for the following
divs (the value "+1" is equivalent to "1").

Not true, +1 means "the previous's div z-index PLUS 1"
If you have three panes, just setting z-index on "details" won't
work. Switching to the second pane, you will see that its links still
doesn't work, because they are being "overlayed" by the third pane.


I have tested it ant it worked like a charm...
JW

Jul 20 '05 #5
Janwillem Borleffs wrote:
I have tested it ant it worked like a charm...


In case you don't believe me:
http://www.jwscripts.com/playground/test.php
JW

Jul 20 '05 #6

"Janwillem Borleffs" <jw@jwscripts.com> wrote in message
news:3f***********************@news.wanadoo.nl...
Janwillem Borleffs wrote:
I have tested it ant it worked like a charm...


In case you don't believe me:
http://www.jwscripts.com/playground/test.php
JW


Nonsense,

try

<div
style="z-index:3;background:red;position:absolute;left:10px ;top:10px;width:3
0px;height:30px"></div>

<div
style="z-index:+1;background:green;position:absolute;left:2 0px;top:20px;widt
h:30px;height:30px"></div>

<div
style="z-index:+1;background:blue;position:absolute;left:30 px;top:30px;width
:30px;height:30px"></div>

and compare to

<div
style="z-index:3;background:red;position:absolute;left:10px ;top:10px;width:3
0px;height:30px"></div>

<div
style="z-index:4;background:green;position:absolute;left:20 px;top:20px;width
:30px;height:30px"></div>

<div
style="z-index:5;background:blue;position:absolute;left:30p x;top:30px;width:
30px;height:30px"></div>

If what you say is true these would be equivalent. Your browser will nodoubt
show you otherwise (or it is seriously flawed).

Silvio Bierman
Jul 20 '05 #7
"Janwillem Borleffs" <jw@jwscripts.com> writes:
Lasse Reichstein Nielsen wrote:
Nope. Setting the z-index of this div does nothing for the following
divs (the value "+1" is equivalent to "1").
Not true, +1 means "the previous's div z-index PLUS 1"
Not in CSS 2. I can't guarantee that some browser won't understand it
as such, but the CSS 2 Recommendation (and CSS 2.1 Working Draft) says:

'z-index'
Value: auto | <integer> | inherit

An <integer> value has an optional prefix sign, with plus being the
default. That is, adding a prefix plus makes no difference. It makes
no mention of the integer being relative to any other element's
stacking level. It just sets the stacking level of this element in
its stacking context to the value specified.

Z-index:
<URL:http://www.w3.org/TR/CSS2/visuren.html#z-index>
Integer:
<URL:http://www.w3.org/TR/CSS2/syndata.html#value-def-integer>

Also, *no* CSS property refers to a *previous* div's properties. If
anything, they refer to the values on surrounding (parent) elements,
using the "inherit" keyword or using percentages of its parent's size,
font-size, etc.
I have tested it ant it worked like a charm...


My test failed.

I took the example code given, added a third pane by copying the
second and changing the id (adding a "2" at the end), changed one of
the lines in each to a link, added a third function and a third case
to the two existing functions, an extra link to call the third
function, and put z-index:1 on the first div ("details").

Then I loaded the page, clicked on the second link to activate the
second pane, and the link in that pane wasn't active until I had
activated the third pane once.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #8
"Janwillem Borleffs" <jw@jwscripts.com> writes:
Janwillem Borleffs wrote:
I have tested it ant it worked like a charm...


In case you don't believe me:
http://www.jwscripts.com/playground/test.php


Ah, you still only have two panes. In that case it is sufficient to
set z-index on the first. The problems appear when a pane is shown
before one that is later in the document and has the same z-index.
That requires three panes, as this example shows:
<URL:http://www.infimum.dk/privat/threepanebug.html>
I have added the third pane and given the first pane z-index:1.
You can reproduce the problem by clicking "Capabilities" and
then try using the links below.

You can probably avoid the problem by setting decreasing z-indices
on all the panes, but that soon gets annoying to maintain.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #9
Janwillem Borleffs wrote:
<div id="details" style="position:absolute;visibility:visible;z-index:+1">

This way, all following divs will automatically get this div's z-index +
1.


Not true. z-index:+1; is the same as z-index:1;

See:
<http://jigsaw.w3.org/css-validator/validator?text=div%7Bposition%3Aabsolute%3Bvisibil ity%3Avisible%3Bz-index%3A%2B1%7D&warning=1&profile=css2&usermedium= all>
and <http://www.w3.org/TR/CSS2/visuren.html#z-index>

--
David Dorward <http://dorward.me.uk/>
Jul 20 '05 #10
Silvio Bierman wrote:
If what you say is true these would be equivalent. Your browser will

nodoubt show you otherwise (or it is seriously flawed).


I see your point, but when `+1` does equal `1`, what's the use of appending
the plus sign or enabling it to be appended at all?
JW

Jul 20 '05 #11

"Janwillem Borleffs" <jw@jwscripts.com> wrote in message
news:3f*********************@news.wanadoo.nl...
Silvio Bierman wrote:
If what you say is true these would be equivalent. Your browser will nodoubt show you otherwise (or it is seriously flawed).


I see your point, but when `+1` does equal `1`, what's the use of

appending the plus sign or enabling it to be appended at all?
JW


The leading plus is simply a (superfluous) unary prefix operator with no
other use than being the opposite of unary -. So +3 is the same as 3
whatever the context.

Silvio Bierman
Jul 20 '05 #12
Silvio Bierman wrote:
The leading plus is simply a (superfluous) unary prefix operator with
no other use than being the opposite of unary -. So +3 is the same as
3 whatever the context.


Thanks for the explanation, it seems that I have always interpreted that one
incorrectly.
JW

Jul 20 '05 #13
"Janwillem Borleffs" <jw@jwscripts.com> wrote in message news:<3f***********************@news.wanadoo.nl>.. .
Janwillem Borleffs wrote:
I have tested it ant it worked like a charm...


In case you don't believe me:
http://www.jwscripts.com/playground/test.php
JW


I have used the z-index+1 and it has worked a treat. Thank you
everybody for your help.

Happy new Year

Dafydd
Jul 20 '05 #14
"Janwillem Borleffs" <jw@jwscripts.com> wrote in message news:<3f***********************@news.wanadoo.nl>.. .
Janwillem Borleffs wrote:
I have tested it ant it worked like a charm...


In case you don't believe me:
http://www.jwscripts.com/playground/test.php
JW


Oh no :-( the links in the other pages still don't work. The one thing
I have done is use the onLoad() in the body tag to load all the div
layers in one go. This solve the problem but could lead the user to
beleive they have visited all the pages as the links change color. The
other problem could be the download time could be increased? I have
broadband so I can't tell if it makes any difference

I know I can use CSS to set vlink to the same color as link but the
user can change the preferences to overide the CSS or so I am told.

Best Wishes Dafydd Eveleigh
Jul 20 '05 #15

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

Similar topics

4
by: Rob Wahmann | last post by:
Hello - I'm using the following syntax: WHERE pages.ParentID=0 AND CONTAINS(pages.regionID,'#request.thisRegion#') ....and I get the folowing error: Execution of a full-text operation...
11
by: rajarao | last post by:
hi I want to remove the content embedded in <script> and </script> tags submitted via text box. My java script should remove the content embedded between <script> and </script> tag. my current...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
5
by: Linda | last post by:
Greetings: I have found a random image script that I like. It is located here: http://www.javascriptcity.com/scripts/local/simage3.htm I'd like to edit this to have 4 different slots for...
4
by: Suhail A, Salman | last post by:
Hi, am not a ASP.NET programmer, and it seems that i have to learn web development, so i need help learning java script. any links to some good sites would be very helpfull. thanks
3
by: IntraRELY | last post by:
Hello, I am having an issue with this java code for a pop-up. window.open('clientsCreate.aspx',null,','_blank,height=350,width=750,menubar =no,status=no,toolbar=no') I need the ability to...
8
by: Ed Jay | last post by:
I want to use history.go() to navigate between my previously loaded pages. I'm looking for a way to trigger a function call when a page is accessed using history.go(). Is there an event generated?...
8
by: dbaplusplus | last post by:
I worked on web development using java script many many years, so I am now a newbie to javascript. I have a single html page, which is generated dynamically using some programming language. Web...
9
by: ajos | last post by:
hi all, im getting some problems in my javascript validations..... my jsp code--> 8: <head> 9: <title>Budget Master Administration</title> 10: <meta name="GENERATOR" content="Microsoft...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.