Log in

View Full Version : Javascript for replacing a target tag in a form for XHTML Strict?



vensland
07-02-2007, 06:30 PM
I am getting a warning that I cannot use a target tag in a form for strict XHTML, I am sure there is a way to do this using javascript, but I just don't know enough to code it myself. Any suggestions? Here is my code:


<form action="http://www.feedburner.com/fb/a/emailverify" method="post" target="popupwindow"
onsubmit="window.open('http://www.feedburner.com', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true">
<p>Enter your email address here:<br />
<input type="text" style="width:119px" name="email" />
<input type="hidden" value="http://feeds.feedburner.com/~e?ffid=990626" name="url" />
<input type="hidden" value="Read-How.com - The Entrepreneurial Products Super Store!" name="title" />
<input type="hidden" name="loc" value="en_US" />
<input type="submit" value="Subscribe" />
</p></form>

Thanks!

Twey
07-02-2007, 06:44 PM
You probably don't want to use XHTML -- it's not yet supported by IE.

target is invalid in strict HTML too. To load in a new, named window:
onclick="open(this.href, 'window_name');"This is equivalent to:
target="window_name"For a frame (although you obviously can't use frames in Strict DOCTYPEs, just for reference):
onclick="frames['frame_name'].location.href = this.href;"Then there are the special ones: _self:
onclick="location.href = this.href;"_top:
onclick="top.location.href = this.href;"_parent:
onclick="parent.location.href = this.href;"

vensland
07-02-2007, 07:14 PM
Twey,

Thanks for the help. Can I ask for a bit more? How would I actually use the options you outlined in my code? I already have a an onsubmit deal so I am not sure how to incorporate your suggestions.


<form action="http://www.feedburner.com/fb/a/emailverify" method="post" target="popupwindow"
onsubmit="window.open('http://www.feedburner.com', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true">

Also, I am not sure what you meant by XHTML is not supported by IE? I am actually using Expression Web with the setting of IE 6 & Strict XHTML version 1.0 as my rules validation.

Thanks!

Twey
07-02-2007, 08:04 PM
Oh, I see, you have the target attribute on a form... that's a lot trickier, and would probably involve some serious application of XMLHttpRequest. If I were you, I'd leave it and submit to the same window.
Also, I am not sure what you meant by XHTML is not supported by IE? I am actually using Expression Web with the setting of IE 6 & Strict XHTML version 1.0 as my rules validation.I suspect your server is probably sending it as HTML (text/html) instead of XHTML (application/xhtml+xml). Thus, browsers won't actually attempt to parse it as XHTML, they'll see it as invalid HTML.