Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms & Anchors 4

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
I'm confused i've tried to validate an XHTML page and I get the following error.
there is no attribute "target".
for this line
Code:
<form id="stationery" action="<tmpl_var NAME='url_to_cgi'>/stationery.cgi" method="post"  target="_blank">

yet I visited this link which clearly indicated it is an attribute of the form tag, can someone explain what is going on please.

also I have had to replace the "name" attribute to "id" does that mean i can no longer talk to the dom via "document.FORMNAME.fieldname.value=foo", and I will have to replace all those with document.getElementById('idname').value = foo"

I also had an anchor <a name="name"> to enable quick links within the page, but i get the following error
there is no attribute "name".

does the browser recognise <a id="name"> as the same, so if i put <a href="#name"> will it still jump to the right place?

thanks
1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Also, read the actual comments that the W3C validator gives:
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
To your first question, validator is right. In XHTML strict there is no target attribute. This highly controversial choice was made because it can cause opening a new browser window, which is manipulation of client's computer, which should not be part of what html is there to do. For such manipulations javascript should be used. To still use target attribute, you would need to revert to xhtml transitional I believe.

For the second question, yes, id should work just as good as name in most modern browsers.
 
hmmm, i think i'll just go back to HTML, i was going to re-write this whole project with XHTML, but is causing more problems than is worth.

Vragabond - does this mean <a href="blank.htm" target="_blank"> will not work, has target been deprecated alltogether?

this would mean, where i had to rewrite due to pop up blockers stopping my javascript along with windows SP2, so I changed the site and used "target" instead of "window.open" i have to go back to window.open with XHTML and all the inherent problems that causes.

doesn't seem right to me, what benefit over HTML4-Strict would XHTML1-Transitional give me.

thanks
1DMF



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Basically, it isn't as strict!

It also means that you can use the target attribute of the form (which in turn means you don't have to rely on the javascript function and people without javascript functionality won't wonder what the button does!).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
i guess i was trying to get things too perfect and as Dan/Jeff has mentioned, getting the right doc-type is not as easy as you first think.

so what would you go for XHTML-Transitional or HTML-Strict.



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Personally, I try to go with Strict for most of my applications but only you can decide what's best for your site as only you know what it does and how it's been coded.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
so you code HTML rather than XHTML, which I think Jeff/Dan said actually you'd be better off than XHTML, which seemed to be replacing HMTL, but posted an article which suggested otherwise and that if you are not serving up XML, you shouldn't use XHTML, if you are serving text/html then HTML should be your doctype.

now i'm going to have to remove all those pesky end tag forward slashes - lol

thanks for the feedback.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Sorry, I misread your post - No I meant that I try to go with XHTML 1.0 Strict if I can.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
so how to you get a form or anchor to post/open to a new window if target is deprecated.

"window.open" doesn't work with popup blockers/sp2 and especially Norton Internet Securities software.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
I try not to do it. My take on the matter is that we shouldn't force things to open in a new window as we are then meddling with the users browsing experience (as it wasn't their choice - if they wanted to open a new window then they can do it themselves i.e hold down shift while clicking a link in IE etc).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
that's assuming too much of the users. many don't know wha tthe shift/ctrl or windows keys are!

They don't know what firewall/virus etc. they have installed.

This makes it very difficult to achieve certain functions with the members area.

in this cenario it is required for the button/link clicked to open a secure browser window and load the required stationery item they selected (word doc/pdf/excel) etc...

i guess for this functionallity i need to choose a doc-type which allows targeting to a new window.

so it's back to the question.... which is better HTML-Strict or XHTML-Transitional

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Doe any of the map links on this page open in new windows for you 1DMF? They work for me wherever I've tested them.


Although I used inline JS, I did it in such a way that the link will still work if JS is unavailable.
Might not work in your forms context, but it might set you in the right direction.

Foamcow Heavy Industries - Web design and ranting
Buy Languedoc wines in the UK
 
that's assuming too much of the users.
I don't think it is. If they know how to do it (and want to) then they will. If they don't know how to do it, then why force it upon them (after all, they didn't ask for it to happen so it may confuse them further that sometimes new windows open and sometimes they don't, even though they performed the same action)?

so it's back to the question.... which is better HTML-Strict or XHTML-Transitional
I don't think that's a question anyone here can answer as it will be down to the type of application you are creating and how it's been coded. Only you know the answer to those questions and therefore it's you who has to answer your own question.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
In fact, almost all pop-up blockers will allow new windows (through window.open) when a user is clicking on a link. They realise it's not an advertising popup, it's generated by the user's action.

But I'm not convinced there's a case for a form submitting to a new window.

And when you're using window.open on a link, make sure you give a valid href, so the link still works with JavaScript disabled:
Code:
<a href="myPopupPage.html" onclick="window.open(this.href); return false;">view stationery</a>

---
Marcus
better questions get better answers - faq581-3339
accessible web design - zioncore.com
 
Code:
<a href="myPopupPage.html" onclick="window.open(this.href); return false;">view stationery</a>

That's how I did it in the example I posted.
But I would tend to agree that new window's should generally be left to the discretion of the visitor.
There are cases where it is desirable though, one needs to look at the whole picture as to why they are clicking a link/submitting a form. Only then can it be determined what is the most friendly way to present your application/site.

Foamcow Heavy Industries - Web design and ranting
Buy Languedoc wines in the UK
 
He was using target='blank' on a form not a link. Anyway - why make things so complicated - just use XHTML transitional.

Keep the back slashes, use target='blank' and stick a transitional doc type on the page. Done.
 
don't you find Norton stops the window.open even if you have it (this.href) ?

i have found users have to hold CTRL when clicking the link to get round this which is not preferable at all.

Thus turning to the FORM method submitting the URL vars via the form instead, checking user is logged in, copying the required file to the secure area and then redirecting the new browser window via the PERL script.

worked like a dream until XHTML. Not allowing a new window when the user has CLICKED something is going to far, i'm all for blocking pop-ups, but this isn't a pop up the user has chosen to click and EXPECTS the document to open in a new window.

chenging the doc type looks like the easiest solution, at least i'll have valid markup for the doctype, which is my current goal, changing all my crap code and non valid markup to something valid. I'm even replacing all the tables for divs, not 1 table on this menu page, but replacing the form, that's too much of a re-write.

as always thanks for the input.


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top