views:

19

answers:

1

Hi,

I need to control some script elements, that's why I want to add class attribute to do it. But, w3c says that it's invalid. Some effect, if I add rel or id attribute.

Any other ideas how I can access appropriate script tag?

Doctype: XHTML 1.0 Strict

Thanks,

+1  A: 

Hmmm... Good question. It seems they can't even have an ID.

The only idea that comes to mind is to add your identifying info into the query string:

<script src="http://www.example.com/scripts/script.js?id=my_id&amp;variable=value"&gt;

it's awfully kludgy but if validity is the most important factor.....

Another idea would be storing the data in the # part:

<script src="http://www.example.com/scripts/script.js#id=my_id&amp;variable=value"&gt;

but I would fear unintended consequences with that one. My assumption is browsers will drop the part when requesting scripts but I don't know for sure.

HTML 5 will bring the data: attribute. Chances are those will be legal in script tags, too.

Pekka