[FX.php List] FMSkipRecords

Steve Hannah shannah at sfu.ca
Mon Mar 27 15:46:16 MST 2006


On 27-Mar-06, at 2:23 PM, Kevin Futter wrote:

>>
>> <FORM NAME="sub" METHOD="POST" ACTION="file.php">
>> <input type="hidden" id="data" name="data" value="mydata">
>> </FORM>
>> <a href="javascript:void(0)"
>> ONCLICK="document.sub.submit(); return false;"
>> target="_blank">LINK TEXT HERE</a>
>>
>> This puts a simple form (add hidden elements for any data that you  
>> want
>> to shepherd into the next form submission) right before the link that
>> will use it. Tested in Safari, Firefox (Mac), and IE6.
>>
>> Cheers,
>> dan
>
> Just a quick note about the JavaScript here: please avoid the  
> "javascript:"
> pseudo protocol; it's invalid and clunky,
Not sure in what way this is invalid.
Clunky?  Sounds like personal taste (although  many web developers  
share this personal taste).


> and in your example, not even
> necessary. The "return false" should be sufficient.

True
> Of course, the form will
> fail completely if JS is disabled or unavailable.
>
> Additionally, if you're going to use hrefs, they should point a  
> legitimate
> URI. If no such thing exists for your purpose, then you can simply  
> use the
> onclick handler on a more appropriate element, such as <span> or  
> even <p>.
I agree with the spirit of this comment (not using the wrong tag for  
the wrong job), but in this case an <a href> is the most appropriate  
tag because this IS a link.  You click it, and it takes you to  
another page.  Clearly this is NOT a paragraph (p) and it is not just  
a span of text ... it is a link and thus should be represented by an  
href.


> You can use CSS to make it look like a traditional link, even  
> changing the
> cursor.
True.. but since we are on best practices, it is not a good idea to  
use CSS to make one semantic element look like a different semantic  
element - better to use the right element in the first place.

i.e.,  I think if you drop the javascript:void(0), there is no  
problem with this example.

Best regards

Steve Hannah


>
> -- 
> Kevin Futter
> Webmaster, St. Bernard's College
> http://www.sbc.melb.catholic.edu.au/
>
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>

----------------------------------------
Steve Hannah
Web Services Developer

Faculty of Applied Sciences
Simon Fraser University
shannah at sfu.ca
604-268-7228
Homepage: http://www.sjhannah.com





More information about the FX.php_List mailing list