? Storing Internal Information In An HTML Document (eg Inside Tags)

A

Alec S.

Hi,

I need a way of dividing up my site into "departments". What I want is
to be able to allow some JavaScript functions to perform differently based
on what department the current page is assigned to.

For example, if the user clicks on a link in a page, the link fires off
a JS function that checks what department the page is in and does something.
If the user clicks on that link on a different page assigned to a different
department, the function does something else.

What I tried to do was to put in an invisible DIV element in the pages
where the ID attribute of the DIV is "_dept_" and the NAME attribute is
whatever the department is. The JS function looks for the _dept_ element
and reads it's name attribute. The problem with this is that when I try to
validate the page I get an error on the name attribute (not in XHTML
Strict).


What can I do?


thanks.
 
O

Oli Filth

Alec said:
Hi,

I need a way of dividing up my site into "departments". What I want is
to be able to allow some JavaScript functions to perform differently based
on what department the current page is assigned to.

For example, if the user clicks on a link in a page, the link fires off
a JS function that checks what department the page is in and does something.
If the user clicks on that link on a different page assigned to a different
department, the function does something else.

What I tried to do was to put in an invisible DIV element in the pages
where the ID attribute of the DIV is "_dept_" and the NAME attribute is
whatever the department is. The JS function looks for the _dept_ element
and reads it's name attribute. The problem with this is that when I try to
validate the page I get an error on the name attribute (not in XHTML
Strict).


What can I do?

If you have access to server-side scripting, use *it* to do this (e.g.
in PHP or ASP). Javascript is a messy way of doing it, as not only does
it rely on the user having Javascript enabled (if they don't then
nothing will work), but you have to include all the different functions
every time you send a page, which is a bit of a waste of bandwidth.
 
A

Alec S.

Oli Filth said:
If you have access to server-side scripting, use *it* to do this (e.g.
in PHP or ASP). Javascript is a messy way of doing it, as not only does
it rely on the user having Javascript enabled (if they don't then
nothing will work), but you have to include all the different functions
every time you send a page, which is a bit of a waste of bandwidth.


Sorry, I forgot to say that I dont' have access to ASP or PHP (or Perl
or SSI or anything useful), my ISP is a piece of crap when it comes to
hosting, they foisted the webspace part of the service off to Geocities of
all things. I'm still using their old one which doesn't have any server
side scripting.
 
M

Mark Parnell

Previously in alt.html said:
I need a way of dividing up my site into "departments". What I want is
to be able to allow some JavaScript functions to perform differently based
on what department the current page is assigned to.
What can I do?

Put an id on the body element.

<body id="departmentname">
 
R

Richard

Alec S. said:
Hi,

I need a way of dividing up my site into "departments". What I want is
to be able to allow some JavaScript functions to perform differently based
on what department the current page is assigned to.

For example, if the user clicks on a link in a page, the link fires off
a JS function that checks what department the page is in and does something.
If the user clicks on that link on a different page assigned to a different
department, the function does something else.

What I tried to do was to put in an invisible DIV element in the pages
where the ID attribute of the DIV is "_dept_" and the NAME attribute is
whatever the department is. The JS function looks for the _dept_ element
and reads it's name attribute. The problem with this is that when I try to
validate the page I get an error on the name attribute (not in XHTML
Strict).


What can I do?


I use a simple script that activates a certain division based upon the
user's click.

var kid = "FirstOn"
function ShowInfo(DivId)
{
document.getElementById(kid).style.display = 'none';
document.getElementById(DivId).style.display = 'block';
kid = DivId;
}

This calls the linked division.
<li><div style="background:#0fF;" onclick="ShowInfo('FirstOn');
changetext(content[0]); swap('images/saturn.gif')">Home</div></li>

Which shows this:
<div id="FirstOn" style="display: block;">

For another linked division:
<div id="th101" style="display:none;">

In any division you can do what ever you want.
Activate a script if desired.
Which can all be done on the same page.

www.somestuff.batcave.net/
 
T

Toby Inkster

Alec said:
What I tried to do was to put in an invisible DIV element in the pages
where the ID attribute of the DIV is "_dept_" and the NAME attribute is
whatever the department is.

This is the perfect use for the META element.

<meta name="department" content="sales">

<script type="text/javascript">
var metas = document.getElementsByTagName('META');
for (var i=0 ; i<metas.length ; i++)
if (metas.getAttribute('name') == "department")
break;
var dept = metas.getAttribute('content');
</script>
 
J

Jukka K. Korpela

Alec S. said:
I need a way of dividing up my site into "departments".

You have multiposted your question, hence saying that you are not
interested in constructive discussion.
 
J

JDS

Sorry, I forgot to say that I dont' have access to ASP or PHP (or Perl
or SSI or anything useful), my ISP is a piece of crap when it comes to
hosting, they foisted the webspace part of the service off to Geocities of
all things. I'm still using their old one which doesn't have any server
side scripting.

Recommended: Find another ISP. At least, find one to host your website.
There are gazillions of web hosts out there that provide server-side
scripting at a very low cost.
 
A

Alec S.

I use a simple script that activates
a certain division based upon the
user's click.
...
For another linked division:
<div id="th101" style="display:none;">

In any division you can do what ever you want.
Activate a script if desired.
Which can all be done on the same page.


The problem with this is that I don't know what the ID would be in
advance. I needed a way of looking for a specific known tag variable and
reading the unknown data from it.
 
A

Alec S.

Toby Inkster said:
This is the perfect use for the META element.

<meta name="department" content="sales">

<script type="text/javascript">
var metas = document.getElementsByTagName('META');
for (var i=0 ; i<metas.length ; i++)
if (metas.getAttribute('name') == "department")
break;
var dept = metas.getAttribute('content');
</script>



That's perfect. It's exactly what I was looking for. Prompted by the
logic of your suggestion, I checked it out and it seems that this purpose is
precisely what meta tags are for: "meta information in this area is used to
communicate information that a human visitor may not be concerned with". I
put it in right away and it works like a charm and validates wonderfully.

Thank you very much.
 
A

Alec S.

You have multiposted
your question, hence saying that you are not
interested in constructive discussion.


No, it means that I have looked for the most apt places to ask in order
to expedite a solution. Not everyone frequents all of the three newsgroups
I posted in. I did not crosspost, in fact I took the time to post to them
individually instead of just throwing in 100 addresses in the to line. You
are partly right however, I am not interested in discussion, I am far too
busy for that. I am only interested in a quick and clear cut answer that I
can immediately implement. Your complaint-which was anything but
constructive-did not help. I did get three other suggestions that were
exactly what I needed. Thanks anyway.

Oh, and before you bother pointing out that I am discussing when I said
I don't have time for, you should take a look at the timestamp.
 
J

Jukka K. Korpela

Alec S. said:
I did not crosspost, in fact I took the time to post to them
individually instead of just throwing in 100 addresses in the to line.

Indeed. That makes you a nuisance.
You are partly right however,

You misspelled "completely".
I am not interested in discussion, I am
far too busy for that.

Thank you for clarification. Please keep using your forged From field as it
is, until you have a clue and something useful to say. Thank you in
advance.
 
M

Mark Parnell

Previously in alt.html said:
No, it means that I have looked for the most apt places to ask in order
to expedite a solution.

And then asked it separately in each of them, instead of tying them
together.
Not everyone frequents all of the three newsgroups
I posted in.

So by multiposting, you make it impossible for them to know whether
someone else has already answered your question in a different group.
I did not crosspost

Exactly. But you should have.

Crosspost, don't multipost
http://oakroadsystems.com/genl/unice.htm#xpost
Why and how to crosspost
http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
 
A

Alec S.

Mark Parnell said:
someone else has already answered your question in a different group.

...
Crosspost, don't multipost
http://oakroadsystems.com/genl/unice.htm#xpost
Why and how to crosspost
http://www.cs.tut.fi/~jkorpela/usenet/xpost.html


Thank you for the information. Unlike others' nagging you pointed out
the problem and offered a solution. Your points and links were very
helpful.

The reasons I multiposted instead of crossposted were: 1) I have seen
people complaining about crossposting-I guess there will always be people
pissed off no matter what you do, some people thrive on conflict. 2) There
were multiple groups that were relevant.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top