views:

337

answers:

4

I am confused. I need to name my iframe in order to use the name as the target in my menu's hypelinks. According to my Visual Web Developer Express the name attribute is considered outdated and a new construct is required. My question is what attrbute code do I utilize to name my iframe. Thank you

A: 

Typically, you would use the "id" attribute as a replacement. This is not always "optimal". I have noticed that this does not always work for named anchors, for instance.

Ishmael
'id' does not (and is not supposed to) work for identifying link targets.
bobince
A: 

Ignore the warning. Believe the DOCTYPE specification. The name attribute is just fine. In fact, HTTP posts via embedded HTML forms pass data using the name attribute as the key.

<input id="txtName" name="name" />

To get at the textbox value in your Page_Load, you would use Request.Form("name"), and not Request.Form("txtName")

When in doubt about attributes and such, run your rendered HTML through the W3 validator to validate it against the DOCTYPE.

Josh Stodola
Correction: the name construct is considered outdated on all elements EXCEPT form elements, as ids will not work for radio button inputs.
R. Bemrose
'name' on input of course has a different meaning to 'name' on [i]frame. It is this overloading of the meaning of 'name' that the move to 'id' was aimed at relieving. 'id' won't work as a control name specifier for any type of form element, not just radios. 'id' is for anchors and scripting hooks.
bobince
+1  A: 

According to my Visual Web Developer Express the name attribute is considered outdated and a new construct is required.

Then Visual Web Developer Express is wrong. For the purposes of anchors and scripting/styling hooks, 'name' is to be replaced by 'id', but for the purpose of identifying link targets (such as frames), it is not. See http://www.w3.org/TR/REC-html40/present/frames.html#adef-target , http://www.w3.org/TR/REC-html40/present/frames.html#adef-name-IFRAME .

This usage is not deprecated in HTML terms, but it's a bit of a code smell. Targeting a link to an iframe is generally considered a bad thing as it breaks many normal navigational expectations. There are uses for it, but be wary.

bobince
Thanks for that reference.
Ishmael
A: 

thank you all for your comment! I found them very helpful! :-)