开发者

script attributes

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 re开发者_如何学编程l or id attribute.

Any other ideas how I can access appropriate script tag?

Doctype: XHTML 1.0 Strict

Thanks,


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&variable=value">

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&variable=value">

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜