Avatar

Expand-Image without JavaScript (Technics)

by Alfie ⌂, Vienna, Austria, Saturday, March 24, 2007, 00:23 (6237 days ago) @ Alfie

Hm, this is IMHO no help for users that have deactivated JavaScript. More appropriate would be linking to the entry. But actually in this case there's no alternative if JavaScript isn't available so we should consider displaying the preview link with document.write.

Hey, you are fast!

The masking of JS right now follows HTML4.01 notation:

script type="text/javascript">
<!--
document.write(' <a href="#" onclick="ajax_preview(226); return false"
title="Show preview">
<img src="templates/default/images/ajax_preview.png" 
alt="Show preview" width="11" height="11" /></a>')
//-->
</script>

For XHTML it should read

script type="text/javascript">
<* <![CDATA[ */
document.write(' <a href="#" onclick="ajax_preview(226); return false"
title="Show preview">
<img src="templates/default/images/ajax_preview.png" 
alt="Show preview" width="11" height="11" /></a>')
/* ]]> */
</script>

instead.

You also may omit either the 'width' or the 'height' statement of any image (if no resizing is done, there is no difference in performance of rendering, but keeps the code at least a little bit smaller - and the spirit of mlf high.

A further improvement would be referring to either a script in the <head> or even an external script, which contains the 'document.write'-stuff. Assignment would just contain the thread's id as a variable.

--
Cheers,
Alfie (Helmut Schütz)
BEBA-Forum (v1.8β)

locked
21783 views

Complete thread:

 RSS Feed of thread