By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 2,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.

--
Alec S.
alec <@> synetech <.> cjb <.> net
Jul 23 '05 #1
Share this Question
Share on Google+
16 Replies


P: n/a
> 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?


Try using the id attribute instead of name.
Jul 23 '05 #2

P: n/a
Alec S. wrote:
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


Abuse another attribute -- say, title -- for this purpose. Or, even
better, stop trying to use such a broken technique.
Jul 23 '05 #3

P: n/a
"Leif K-Brooks" <eu*****@ecritters.biz> wrote in message
news:36*************@individual.net...
Or, even better, stop trying to use such a broken technique.


I would if you had suggested another way to do this. What exactly do
you mean by a "broken technique"?

--
Alec S.
alec <@> synetech <.> cjb <.> net
Jul 23 '05 #4

P: n/a
"Mr.Clean" <mrclean@p&g.com> wrote in message
news:1107288966.7d168ba6975cb17ed63b72fb7da6ebf7@t eranews...
Try using the id attribute instead of name.


I can't do that. I need a way of getting the element and reading it.
If I put the department name in ID, then I would have no way of finding the
tag in the first place.
--
Alec S.
alec <@> synetech <.> cjb <.> net
Jul 23 '05 #5

P: n/a
Please don't multi-post. See
<URL:http://www.cs.tut.fi/~jkorpela/usenet/xpost.html>.

Alec S. wrote:
"Leif K-Brooks" <eu*****@ecritters.biz> wrote in message
news:36*************@individual.net...
Or, even better, stop trying to use such a broken technique.
[...] What exactly do you mean by a "broken technique"?


As Leif pointed out, you're abusing an attribute[1] just to hack some
client-side script. Your original post also seems to attach importance
this script which, depending on your target audience, could be
considered broken, too.

Script data is script data. If you can't discern enough information
from the content itself, create an appropriate data structure and grab
the data from there. That said, I suspect you could examine the link,
if we continue that example, and determine where it goes - somewhere
in the current department or to another. That should provide enough
information on which you can base your decision.
--


Signature separators are composed of two dashes, followed by a space.
Newsreaders won't generally recognise a signature without the trailing
space.

Mike
[1] A non-existent one at that: DIV elements don't have name attributes.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #6

P: n/a
Alec S. wrote:
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.
DIV doesn't *have* a NAME attribute.
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?


You're already using Javascript, so why wouldn't you just use

<script type="text/javascript">
var dept = "blahblah"
</script>

?
Jul 23 '05 #7

P: n/a
"Michael Winter" <m.******@blueyonder.co.invalid> wrote in message
news:8r*****************@text.news.blueyonder.co.u k...
As Leif pointed out, you're abusing an attribute[1] just to hack some
client-side script. Your original post also seems to attach importance
this script which, depending on your target audience, could be
considered broken, too.

Script data is script data. If you can't discern enough information
from the content itself, create an appropriate data structure and grab
the data from there. That said, I suspect you could examine the link,
if we continue that example, and determine where it goes - somewhere
in the current department or to another. That should provide enough
information on which you can base your decision.
I am doing it this way to consolidate similar functions. Obviously I'm
not a pro and never claimed to be which is why I'm asking here.

Signature separators are composed of two dashes, followed by a space.
Newsreaders won't generally recognise [sic] a signature without the trailing space.


That's the way I've been doing it for the past 10 years but I'll look
into this.
--
Alec S.
alec <@> synetech <.> cjb <.> net
Jul 23 '05 #8

P: n/a
"Harlan Messinger" <hm*******************@comcast.net> wrote in message
news:36*************@individual.net...
You're already using Javascript, so why wouldn't you just use

<script type="text/javascript">
var dept = "blahblah"
</script>

Because then every page that uses the script would be assigned to the
same department. I want the script to perform slightly differently
depending on which department the page itself is reporting.

--
Alec S.
alec <@> synetech <.> cjb <.> net

Jul 23 '05 #9

P: n/a
"Alec S." <a@a.com> wrote:
"Harlan Messinger" <hm*******************@comcast.net> wrote in message
news:36*************@individual.net...
You're already using Javascript, so why wouldn't you just use

<script type="text/javascript">
var dept = "blahblah"
</script>


Because then every page that uses the script would be assigned to the
same department.


You could have different value on different pages. Writing a single
<div id="dept" name="foo"></div> into a page can't be much easier than
writing a single script element such as the one above.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 23 '05 #10

P: n/a
Alec S. wrote:
"Harlan Messinger" <hm*******************@comcast.net> wrote in message
news:36*************@individual.net...
You're already using Javascript, so why wouldn't you just use

<script type="text/javascript">
var dept = "blahblah"
</script>

Because then every page that uses the script would be assigned to the
same department.


Huh? Why? Are you incapable of replacing "blahblah" with the name of one
department on one page and the name of a different department on another
page?
Jul 23 '05 #11

P: n/a
"Alec S." <a@a.com> wrote in news:yo********************@rogers.com:
I need a way of dividing up my site into "departments".


Instead of suggesting the answer lies with the use of
javascript, try explaining what it is you want to do,
along with an example(even better if you provide a URL).
For example, my first though is "server-side scripting",
but it's not clear really what you want/need to do.

--
Dave Patton
Canadian Coordinator, Degree Confluence Project
http://www.confluence.org/
My website: http://members.shaw.ca/davepatton/
Jul 23 '05 #12

P: n/a
Nevermind, I got a suggestion from someone elsewhere. In case anyone
wants to know, it was to use a meta tag. Brilliant!
--
Alec S.
alec <@> synetech <.> cjb <.> net

Jul 23 '05 #13

P: n/a
Tim
"Michael Winter" <m.******@blueyonder.co.invalid> wrote
Signature separators are composed of two dashes, followed by a space.
Newsreaders won't generally recognise [sic] a signature without the
trailing space.

"Alec S." <a@a.com> posted:
That's the way I've been doing it for the past 10 years but I'll look
into this.


It's because you posted using Outlook Express, and it has a flaw in this
regard: It considers such trailing spaces to be extraneous, and removes
them, unless you patch the program with something else (such as the
"oequotefix" program, which also makes a number of improvements to how OE
quotes messages).

--
If you insist on e-mailing me, use the reply-to address (it's real but
temporary). But please reply to the group, like you're supposed to.

This message was sent without a virus, please delete some files yourself.
Jul 23 '05 #14

P: n/a
"Tim" <ti*@mail.localhost.invalid> wrote in message
news:15******************************@40tude.net.. .> It's because you posted
using Outlook Express, and it has a flaw in this
regard: It considers such trailing spaces to be extraneous, and removes
them, unless you patch the program with something else (such as the
"oequotefix" program, which also makes a number of improvements to how OE
quotes messages).


No, actually that's the way I've been doing it long before Outlook
Express existed. I use that in everything from forums to IM. It's just the
way I got used to doing it back in the BBS days. In fact OE insists on
putting a "-- " in to divide the signature regardless of what I have in it.
I'll take a look at oequitefix though. I hope it also fixes the way OE
messes with line breaks, I really hate that.
--
Alec S.
alec <@> synetech <.> cjb <.> net
Jul 23 '05 #15

P: n/a
Alec S. wrote:
In fact OE insists on putting a "-- " in to divide the signature
regardless of what I have in it.
No, actually it put in a "--" without the required space. <g>
I'll take a look at oequitefix though. I hope it also fixes the
way OE messes with line breaks, I really hate that.


OE-Quotefix is supposed to fix all that. Or ... get a modern newsreader!

--
-bts
-This space intentionally left blank.
Jul 23 '05 #16

P: n/a
Tim
"Tim" <ti*@mail.localhost.invalid> wrote in message
It's because you posted using Outlook Express, and it has a flaw in this
regard: It considers such trailing spaces to be extraneous, and removes
them, unless you patch the program with something else (such as the
"oequotefix" program, which also makes a number of improvements to how OE
quotes messages).

"Alec S." <a@a.com> posted:
No, actually that's the way I've been doing it long before Outlook
Express existed.
You misunderstood what I said... Regardless of what *you* typed into
Outlook Express (i.e. the correct, well recognised, "-- " sequence), it
modified it before sending the message to remove the trailing space.

For this sort of reason, some clients now recognise dash dash end-of-line
as the same thing. And to be honest, I can't see any true value in the
trailing space. A double dash on a line by itself is just as peculiar, and
unlikely to be deliberately typed for some other reason. And the immediate
end-of-line takes care of not mistaking it for anybody trying to simulate a
quote dash in front of a line of text.
In fact OE insists on putting a "-- " in to divide the signature
regardless of what I have in it.
Look closer, you'll discover it doesn't have the trailing space. Perhaps
it's there while originally editing the message, but it won't be
afterwards.
I'll take a look at oequitefix though. I hope it also fixes the way OE
messes with line breaks, I really hate that.


It makes a huge improvement in that area. Quite how OE can be so utterly
crap at quoting, considering how old it is, and the time that's been
available to fix it up, I don't know. But then MSIE is equally crap, and
Windows, and just about anything else made by Microsoft...

--
If you insist on e-mailing me, use the reply-to address (it's real but
temporary). But please reply to the group, like you're supposed to.

This message was sent without a virus, please delete some files yourself.
Jul 23 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.