|
Posted by Gus Richter on May 6, 2008, 7:40 pm
Please log in for more thread options David Stone wrote:
> sheldonlg <sheldonlg> wrote:
>
>> test9991014@yahoo.com wrote:
>>> While visiting the apple.com page, I noticed an unusual
>>> form behavior that seems pretty nice, but looking at the
>>> source (below) it is unclear how it works. Is there a tutorial
>>> that explains it? Thanks.
>>>
>>> <div id="ppu-checker">
>>> <form id="ppu-check-form" onsubmit="return false;" method="get"
>>> action="http
>>> ://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/wa/RSLID">
>>> <p>
>>> </p><div id="ppu-input-container" class="psearch
>>> nonsafari"><label><
>>> input name="ppu-postal-code" maxlength="" size="10" class="psearch
>>> nonsafari" va
>>> lue="Zip code" id="ppu-postal-code" type="text"><span id="ppu-input-
>>> container-re
>>> set"></span></label></div>
>>> <script type="text/javascript">
>>> // <![CDATA[
>>> dojo.require("apple.widget.PrettySearchField");
>>> var ppuinputcontainerObj = new apple.widget.PrettySearchField(
>>> {
>>> inputId: "ppu-postal-code",
>>> containerId: "ppu-input-container",
>>> resetIconId: "ppu-input-container-reset",
>>> maxLength: "5",
>>> results: "",
>>> placeholder: "Zip code",
>>> autosave: ""
>>> }
>>> );
>>> // ]]>
>>> </script>
>> The CDATA lines have been commented out.
>
> It may be a WebObjects thing? Not sure, as I've never actually
> poked into WebObjects, but Apple certainly has...
In XHTML, Script and Style element contents must be wrapped within a
CDATA marked section to avoid expansion of entities < and & as start of
markup and not to recognize < and & as < and & respectively. i.e.
<script>
<![CDATA[
... unescaped script content ...
]]>
</script>
The (//) are javascript single line comments - the CDATA start and end
tags are required for XHTML, but javascript will not see those lines.
--
Gus
|