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.
 
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.

The window not opening is nothing to do with XHTML, that's happened because of all the pop up blockers that are needed to combat those annoying ad spammers!

The XHTML/JS method I showed for links is only needed to retain compliance with the XHTML Strict Doctype. Quite rightly this prevents HTML from affecting browser behavior.

Incidentally, you probably knew this but CTRL+Click will open any link in a new window, always has done.

Granted you initially asked about doing this with a form submit. I've not tried it (yet) but how about adapting the method to work with onSubmit - is that even allowed (I'm a it of a JS dunce)

Foamcow Heavy Industries - Web design and ranting
Buy Languedoc wines in the UK
 
Try this

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en">

<head>
<title>Form Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>
<form action="thanks.html" method="post" language="en" onsubmit="window.open('thanks.html');return false;">
	   Name: <input type="text" value="" id="fld_name" />  <br />
	   <input type="submit" value="submit" id="submit"  />
</form>
</body>
</html>

Make a page called thanks.html to test it.
I *think* that works :)

Foamcow Heavy Industries - Web design and ranting
Buy Languedoc wines in the UK
 
The XHTML/JS method I showed for links is only needed to retain compliance with the XHTML Strict Doctype. Quite rightly this prevents HTML from affecting browser behavior.

Sure I understand this, but lets not get too caught up in having to go XHTML Strict.

The fact that target has been deprecated has nothing to do with browser behaviour but the fact that 'target' has no structural meaning. With this logic it does make sense that window behaviour should be dealt with via scripting.
 
sorry but i think I have confused you slightly.

this ctrl and click, is not for opening windows, Norton Internet Securities seems to be blocking EVERYTHING.

holding CTRL and clicking doesn't open a new window for my member, it just lets the Javascript run, it's a real pain in the ass

I have on occasion used document.href, in the onclick event, this gets blocked along with window.open, it's a Norton/User problem more than anything, norton being to strict and the user not being capable of configuring it to allow our website.

again unfortunately your solution uses 'window.open', i try my best now to never use it, it's blocked by so much stuff it's become nearly useless.

but now my work round has been scuppered by the XHTML Strict doctype. oh well you can't win them all :)



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
foamcow suggested:
Code:
<form action="thanks.html" method="post" language="en" onsubmit="window.open('thanks.html');return false;">
       Name: <input type="text" value="" id="fld_name" />  <br />
       <input type="submit" value="submit" id="submit"  />
</form>

I'm afraid this won't work. It may (popup blockers permitting) popup a new window containing thanks.html, but the data won't be submitted to it. window.open won't submit data (unless you use javascript to encode the variables as GET variables).

---
Marcus
better questions get better answers - faq581-3339
accessible web design - zioncore.com
 
It might be to do with the settings, i'll paste the menu button code i use which doesn't seem to work for some members with Norton, everyone else is fine.

Code:
<img src="/images/lenders1.png\" style="cursor:pointer;" border=0 name="lenders" title="Lender Partners" onmouseover="document.lenders.src='/images/lenders2.png'; window.status='Enter Lenders Area'; parent.msg.document.menuimage.src='/images/fsa-lenders.gif'" onmouseout="document.lenders.src='/images/lenders1.png'; window.status='Please select a menu option'; parent.msg.document.menuimage.src='/images/hlp-menu.gif'" onclick="parent.main.location.href='lenders.cgi'">

this is just an example of many where onclick is killed by Norton, document.location.href, window.open I find are also a nightmare.

and i know the code is a bit ropey in terms of validity, I haven't got to this bit yet, i'm unsure why the standards ended up dropping the 'name' attribute and now you have the long winded way of getElementById instead, but i've learnt not to question now, just go with the flow!


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
By the way, you appear to have an errant \ in your image src.
Code:
<img 
  src="/images/lenders1.png[COLOR=red]\[/color]" 
  style="cursor:pointer;" 
  border=0 name="lenders" 
  title="Lender Partners"
  onmouseover="document.lenders.src='/images/lenders2.png'; window.status='Enter Lenders Area'; parent.msg.document.menuimage.src='/images/fsa-lenders.gif'" 
  onmouseout="document.lenders.src='/images/lenders1.png'; window.status='Please select a menu option'; parent.msg.document.menuimage.src='/images/hlp-menu.gif'" 
  onclick="parent.main.location.href='lenders.cgi'">
1DMF said:
this is just an example of many where onclick is killed by Norton,

You're attaching an onclick location change to an image - which can appear deceptive. instead, attach any location change to a link:
Code:
<a href="lenders.cgi" onclick="parent.main.location.href='lenders.cgi'">
  <img 
    src="/images/lenders1.png\" 
    style="cursor:pointer;" 
    border=0 name="lenders" 
    title="Lender Partners"
    onmouseover="document.lenders.src='/images/lenders2.png'; window.status='Enter Lenders Area'; parent.msg.document.menuimage.src='/images/fsa-lenders.gif'" 
    onmouseout="document.lenders.src='/images/lenders1.png'; window.status='Please select a menu option'; parent.msg.document.menuimage.src='/images/hlp-menu.gif'">
</a>

---
Marcus
better questions get better answers - faq581-3339
accessible web design - zioncore.com
 
sorry i missed one of the escapes (the code is actually in a PERL script)

I know i'm doing that, it seemed easier and quicker to put the onlcick on the image rather than wrapping an anchor around it, which is the approach i will now take - when i get to that page.

I don't see the difference between onclick/a href , they both have the same effect when used in conjunction with location.href and one requires much less coding.

But as you say ,to some blockers i guess they see it as some sinister peice of code ready to infect the users computer and eventually take over the world - yeah right, come on Norton stop being so tight!.




"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
yeah the simple solution was to change doctype and now i have
This Page Is Valid XHTML 1.0 Transitional!
- whoo hoo that's my second valid page only another 67 to go :)



"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