HighDots Forums  

Changing the title and getting attribute values

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Changing the title and getting attribute values in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Max
 
Posts: n/a

Default Changing the title and getting attribute values - 12-31-2007 , 09:36 AM






Two questions:

1. How do I set the title of a document using CSS (preferred) or XSL
(if that's how it has to be done)

2. How can I get an attribute value? For example, if I have the tags
<tag attr="1">...<tag attr="498">, how can I use the value of attr?

I'm assuming both of these are possible, which may be an overlarge
XXXXXXXXL assumption, but I hope not.

Reply With Quote
  #2  
Old   
Rob Waaijenberg
 
Posts: n/a

Default Re: Changing the title and getting attribute values - 12-31-2007 , 10:02 AM






Max schreef:
Quote:
Two questions:

1. How do I set the title of a document using CSS (preferred) or XSL
(if that's how it has to be done)
You don't, at least not with CSS.
You could do it with a scripting language.

Do you know the difference?

Quote:
2. How can I get an attribute value? For example, if I have the tags
tag attr="1">...<tag attr="498">, how can I use the value of attr?

I'm not sure how to interpret this question.
Normally you don't "get" an attribute value, but you give it.
You don't use values. UA's use values.

Quote:
I'm assuming both of these are possible, which may be an overlarge
XXXXXXXXL assumption, but I hope not.
I guess I just don't understand what you really need or want.

--
Rob


Reply With Quote
  #3  
Old   
Joshua Cranmer
 
Posts: n/a

Default Re: Changing the title and getting attribute values - 12-31-2007 , 11:37 AM



Max wrote:
Quote:
Two questions:

1. How do I set the title of a document using CSS (preferred) or XSL
(if that's how it has to be done)
You don't.

Quote:
2. How can I get an attribute value? For example, if I have the tags
tag attr="1">...<tag attr="498">, how can I use the value of attr?
(DISCLAIMER: This information is based off of CSS 3, and is thus subject
to change in the final drafts and subject to be very non-widely
implemented. Not recommended for production use at this stage.)

CSS 3 (Generated content? I don't remember which draft) specifies the
attr() value which can be used like as follows:
font[c] {
color: attr("c");
}

There are strict limits on what can be done with the attr() value, to
which I refer you to the relevant CSS 3 WD.

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth


Reply With Quote
  #4  
Old   
Max
 
Posts: n/a

Default Re: Changing the title and getting attribute values - 12-31-2007 , 12:19 PM



On Dec 31, 12:37 pm, Joshua Cranmer <Pidgeo... (AT) verizon (DOT) invalid> wrote:

Quote:
CSS 3 (Generated content? I don't remember which draft) specifies the
attr() value which can be used like as follows:
font[c] {
color: attr("c");
Oh, thanks!


Reply With Quote
  #5  
Old   
Joshua Cranmer
 
Posts: n/a

Default Re: Changing the title and getting attribute values - 01-01-2008 , 10:40 AM



Joshua Cranmer wrote:
Quote:
CSS 3 (Generated content? I don't remember which draft) specifies the
attr() value which can be used like as follows:
font[c] {
color: attr("c");
}

There are strict limits on what can be done with the attr() value, to
which I refer you to the relevant CSS 3 WD.

Looked up the reference. It's CSS 3 Values and Units, § 3.7.1 The 'attr'
function (http://www.w3.org/TR/2006/WD-css3-va...19/#attribute).

'attr(' ident [ ',' <type> [ ',' <value> ]? ]? ')'

The correct syntax for my example would therefore be:

font[c] {
color: attr(c);
}

A lot is still up in the air in the WD (everything in bright red text).

CSS 2.1 also contains the attr(X) value, but only as a value for the
content property. My Wikipedia reference chart says that IE doesn't
support it; I don't know how the other UAs stack up in reference to the
CSS 3 version.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth


Reply With Quote
  #6  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Changing the title and getting attribute values - 01-01-2008 , 11:08 AM



Scripsit Max:

Quote:
On Dec 31, 12:37 pm, Joshua Cranmer <Pidgeo... (AT) verizon (DOT) invalid> wrote:

CSS 3 (Generated content? I don't remember which draft) specifies the
attr() value which can be used like as follows:
font[c] {
color: attr("c");

Oh, thanks!
Now that we know what took for an answer, it might be interesting to
know what the question is. What did you mean by "getting attribute
values"? Can you formulate your question in CSS terms, or in terms of
(visual) presentation of HTML or XML documents?

(The answer you thank for is pointless, since CSS 3 is just a collection
of incomplete drafts.)

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #7  
Old   
GTalbot
 
Posts: n/a

Default Re: Changing the title and getting attribute values - 01-01-2008 , 01:43 PM



On 31 déc 2007, 10:36, Max <maxh.is.h... (AT) gmail (DOT) com> wrote:
Quote:
Two questions:

1. How do I set the title of a document using CSS (preferred) or XSL
(if that's how it has to be done)

Hello Max,

Everyone who answered you has given you a correct answer: you can not
set the title of a document (or the content of any DOM node) with CSS.
You can do this with javascript.

<title>Old title</title>

(...)

<body onload="document.title = 'New title';" ...>

Not tested.

Quote:
2. How can I get an attribute value? For example, if I have the tags
tag attr="1">...<tag attr="498">, how can I use the value of attr?
Good question, although your choice of the "use" verb makes it
difficult to answer you.

Internet Explorer 6 and Internet Explorer 7 have bugs regarding their
implementation of the DOM methods

hasAttributes() is not supported
http://www.gtalbot.org/BrowserBugsSe...esSupport.html

attributes[] as a NamedNodeMap object is incorrectly implemented
http://www.gtalbot.org/BrowserBugsSe...entation..html

getAttribute() is incorrectly implemented
Attribute nightmare in IE
http://tobielangel.com/2007/1/11/att...ightmare-in-ie


If we knew exactly what you are trying to achieve, to accomplish in a
reduced demo/test case (preferably on a web accessible webpage/URL),
then we would all be able to suggest, propose concrete measures.

Regards, Gérard




Reply With Quote
  #8  
Old   
GTalbot
 
Posts: n/a

Default Re: Changing the title and getting attribute values - 01-01-2008 , 02:14 PM



On 31 déc 2007, 10:36, Max <maxh.is.h... (AT) gmail (DOT) com> wrote:


Quote:
2. How can I get an attribute value? For example, if I have the tags
tag attr="1">...<tag attr="498">, how can I use the value of attr?

Quick code example:

<p id="test" title="Foo">This is a paragraph identified with its id
attribute "test" and its title attribute value is Foo</p>

<p><button type="button" onclick="if(document.getElementById &&
document.getElementById('test') &&
document.getElementById('test').attributes &&
document.getElementById('test').attributes['title']) {alert('The title
attribute value of the \'test\' paragraph is ' +
document.getElementById('test').attributes['title'].nodeValue);};">Show
title attribute</button></p>

This works in Firefox 2.0.0.11, in Internet Explorer 7, in Opera 9.25
and in Safari 3.0.4, Konqueror 3.5.8.

Quick webpage demo:
http://www.gtalbot.org/DHTMLSection/...buteValue.html

(A bit more work would be required to make that webpage better).

Regards and season's greetings, Gérard
--
Internet Explorer 7 bugs
http://www.gtalbot.org/BrowserBugsSection/MSIE7Bugs/


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.