Loading ...
Sorry, an error occurred while loading the content.
 

Re: Dav & Pablo: code works now, but plz xplain -thnx k

Expand Messages
  • kp_yui
    thanks, Pablo - curious about the purpose of the loader. kp
    Message 1 of 9 , Jul 31, 2007
      thanks, Pablo - curious about the purpose of the loader.
      kp

      --- In ydn-javascript@yahoogroups.com, "Pablo Viojo" <pviojo@...> wrote:
      >
      > On 7/31/07, kp_yui <kp_yui@...> wrote:
      > >
      > > Pablo & Dav,
      > >
      > > thanks for responding -
      > >
      > > I had some major errors in my code: first of all there is no inherent
      > > getElementByClass in JavaScript...I finally learned: so the YUI comes
      > > in. I had to get top level help, but here is the code and it's
      working:
      > >
      > > but can someone explain it to me?
      > >
      > > function loader(){
      > > //everything goes here
      > > //object detection to avoid errors on un-supported browsers
      > > if (window.print) {
      > > var elementsOfOurClass =
      > > YAHOO.util.Dom.getElementsByClassName("dynPrintButton");
      > > for(var i=0; i < elementsOfOurClass.length ;i++){
      > > elementsOfOurClass[i].innerHTML='<input type="button"
      > > class="printButton" value="Print Page" onclick="printpage()"/>';
      > > }
      > > }
      > > }//END loader(
      > >
      > > function printpage(){ window.print(); }
      > >
      >
      > Ehmmm, well, let's go
      >
      > * var elementsOfOurClass =
      > YAHOO.util.Dom.getElementsByClassName("dynPrintButton");
      >
      > gets an array of elements with dynPrintButton as className
      >
      > for(var i=0; i < elementsOfOurClass.length ;i++){
      > elementsOfOurClass[i].innerHTML='<input type="button"
      > class="printButton" value="Print Page" onclick="printpage()"/>';
      > }
      >
      > Iterates over the array elementsOfOurClass and replace everyone with a
      > "Print Page" button, which on click calls printpage() (window.print)
      >
      > That's all.
      >
      > I'll suggest trying it and playing for a while to really understand.
      >
      > Regards,
      >
      > --
      > Pablo Viojo
      > pviojo@...
      > http://pviojo.net
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.