[Javascript] Unobtrusive JavaScript?

tedd tedd at sperling.com
Mon Apr 18 09:09:31 CDT 2011


Troy:

Forgive top-posting.

Will address later -- unfortunately, very busy this week.

Thanks for your time and effort -- I will investigate and follow-up.

Cheers,

tedd

----------

At 7:12 AM +0000 4/18/11, Troy III Ajnej wrote:
>Here is an alternative code to think about:
>
>---------------------- 8< ---------------------------------
><!-- trying to hide the html code from RT mail interpreter
><!DOCTYPE native>
><html>
><head>
><title>input fields</title>
></head>
><body>
><form action="index.php" method="post">
><input type='text' size='70' value='Who' class="" READONLY>
><input type='text' size='10' value='What' class="" READONLY>
><input type='text' size='10' value='When' class="" READONLY>
><div id='inputs'>
><input type='text' size='70' name='who[]'>
><input type='text' size='10' name='what[]'>
><input type='text' size='10' name='when[]'>
></div>
><input type="button" name="" value="Add Another Record" onclick="addInput()">
><input type="submit" name="submit" value="Submit">
></form>
><script>
>function addInput(){
>var x = addInput.x||(addInput.x = inputs.innerHTML),
>div = document.createElement("DIV");
>div.innerHTML = x;
>inputs.appendChild(div);
>div.children[0].focus();
>}
></script>
></body>
></html>
>end of try hide -->
>---------------------- 8< ---------------------------------
>!Keep the original doctype.
>
>I will be answering all questions regarding the code if any.
>since it is pretty obvious what it does and how it does.
>
>Although there is space to comment the first line of my
>"cache'n'freeze method" used here for much less important reason.
>Keeping Tedds GVS clean.
>
>There is a more powerful and cleaner method of this function
>but firefox still lacks the support.
>
>@Tedd, -in my opinion:
>there is nothing obtrusive about SCRIPT, the script container tag
>is a legitimate BODY and DOM element since forever.
>
>Moreover, it firstly belongs to the Document BODY, and lastly
>in the Document HEAD where it was later allowed only because
>of browser-sniffing-code requirements of the time. (yeah, silly times)
>
>Explicit code/functions which manipulate and modify the structure
>of the document should exist on the same context. Only reusable
>code and functions require a separate space.
>
>REUSABILITY- That's the only practical reason of why the script
>element was later equipped with the source property - to make the
>same script body reusable in all other pages instead of rewriting/
>pasting it on every page that needed it.
>
>Simply, to avoid redoundancy; to narrow the bandwidth requirements,
>speed-up the page download, etc.:
>"write once use always" or "write here use everywhere" -slogans of
>the time. But there is absolutely no practical reason to separate
>the explicit code from document. It defeats the purpose; slows down
>the page download. (More server requests, more stop-wait-continue.)
>This is also one of the reasons why people use sprites instead of
>say 40 small images. A sprite image loads at least 10 times faster
>than 40 thumbnails.
>
>4-5 <, script sources load ~5 times slower than one complete js
>file at once.
>Not to mention the async error-prone probs...
>
>Regards
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>                Troy III
>       progressive art enterprise
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
>>  Date: Sat, 16 Apr 2011 21:16:45 -0400
>>  To: javascript at lists.evolt.org
>>  From: tedd at sperling.com
>>  Subject: [Javascript] Unobtrusive JavaScript?
>>
>>  To all:
>>
>>  I think I got it.
>>
>>  http://www.webbytedd.com/aa/add-onclick-button/
>>
>>  In summary, if JavaScript is ON, then an onclick-button is added to
>>  the html otherwise nothing happens.
>>
>>  In both cases the form works and allows the user to enter as many
>>  Input Fields as needed. It is just easier if JavaScript is ON.
>>
>>  Considering there is no JavaScript anywhere within the html (other
>>  than the script src reference in the head tags) is an example of
>>  unobtrusive JavaScript -- is that correct?
>  >
>>  Thanks,
>>
>>  tedd
>>  --
>>  -------
>>  http://sperling.com/
>>  _______________________________________________
>>  Javascript mailing list
>>  Javascript at lists.evolt.org
>>  http://lists.evolt.org/mailman/listinfo/javascript 
>>	  		 
>_______________________________________________
>Javascript mailing list
>Javascript at lists.evolt.org
>http://lists.evolt.org/mailman/listinfo/javascript


-- 
-------
http://sperling.com/


More information about the Javascript mailing list