SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question -moz-binding problem on older Geckos

    Hi all,

    I have been working on a XBL file to implement soft hyphenation (& shy; ) support for Geckos pre firefox 3 using -mos-binding:. Follows a working code for firefox 2:

    Code:
    <?xml version = "1.0"?>
    <bindings xmlns = "http://www.mozilla.org/xbl" xmlns:html = "http://www.w3.org/1999/xhtml">
    <binding id = "shy" applyauthorstyles = "false">
       <implementation>
          <constructor>
             <![CDATA[
    
             function hyphenate(container){
                for(var i=0; i<container.childNodes.length; i++){
                   var node = container.childNodes[i];
                   if (node.nodeType == 3){
                      var list = node.data.split('\xAD');
                      var newNode = document.createElement('span');
                      node.parentNode.replaceChild(newNode,node);
                      newNode.appendChild(document.createTextNode(list[0]));
                      var result;
                      for (var i = 1; i < list.length; i++) {
                         var index = list[i].search(/\s/);
                         var block =[list[i].slice(0,index), list[i].slice(index,list[i].length)];
                         var parentSpan = document.createElement('span');
                         parentSpan.appendChild(document.createTextNode('- '));
                         var childSpan = document.createElement('span');
                         var textNode = document.createTextNode(block[0]);
                         childSpan.appendChild(textNode);
                         parentSpan.appendChild(childSpan);
                         newNode.appendChild(parentSpan);
                         if (parentSpan.offsetTop == childSpan.offsetTop) {
                            newNode.replaceChild(textNode,parentSpan);
                         }else{
                            newNode.removeChild(parentSpan);
                            newNode.appendChild(document.createTextNode('- '));
                            newNode.appendChild(textNode);
                         }
                         newNode.appendChild(document.createTextNode(block[1]));
                      }
                   }else{
                      hyphenate(node);
                   }
                }
             }
    
             var element = this;
             hyphenate(element);
    
             ]]>
          </constructor>
       </implementation>
    </binding>
    </bindings>
    Although it was only used standard dom 2 javascript, and -moz-binding: is supported by all Geckos (I think), it do not work in Netscape 7.* nor Netscape 8.

    Do someone have an idea why it do not work, or what can be done in order to work on older Geckos?

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What does the JavaScript console show?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •