Extension development question

Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.

  1. #1

    Default Extension development question

    I have spent several frustrating hours trying to make a Command smart
    enough NOT to process a document containing malformed html (i.e. html
    that does not contain html, head, and body tags, like that in an
    Include file.) But it seems that the DW API outfoxes me at every turn:
    If I experiment with a document that LACKS those tags, DW *invents*
    them so they are present in the document innerHTML, and are present in
    the DOM tree as well.

    Does anyone know a way around this? Any way to properly detect that a
    document lacks any one or all of <html>, <body> and <head> tags?

    Thanks.

    emichael brandt
    E Michael Brandt Guest

  2. Similar Questions and Discussions

    1. No WML development extension for DW8?
      For some mysterious reason, no one can find a WML development extension for DW8. I must be missing a point here, has it been approached differently?...
    2. DW Extension Development Forum not working?!
      Hello all, Trying to login to the devforums for DW extensions and it seems that it is not available. Does anyone know if this is down for good or...
    3. perl template tool kit extension development
      Greetings, I would like to develop an extension to dreamweaver to allow DW to visually display the perl Template Toolkit .wld files. For those...
    4. Question about install Development utiliies on Linux Redhat 7.0
      I install Linux RedHat 7.0 on my Pentium III system..Now I would like to compile the Xfree86 4.3.0 source codes to support my Nvidia GeForce2 MX400...
    5. Development best practices and knowing when to exercise control over development
      Hi Nuno, After analyzing your message, I found that most of it was purely theoretical. The actual issue you discussed was regarding how to...
  3. #2

    Default Re: Extension development question

    Maybe you could try with a regexp ?

    function runCmd(){
    var leDOM = dw.getDocumentDOM();

    var html = leDOM.getElementsByTagName('html')[0];
    var content = html.outerHTML;
    var reg = /<html>/gi;

    if (reg.test(content)) {
    alert('good');
    // Process

    } else {
    alert('bad');
    return;
    }

    window.close();
    }


    >
    > Does anyone know a way around this? Any way to properly detect that a
    > document lacks any one or all of <html>, <body> and <head> tags?
    >
    > Thanks.
    >
    > emichael brandt

    Phil Guest

  4. #3

    Default Re: Extension development question

    You hit the nail just right.

    I am now using this code and it is working nicely. Thanks:


    var h=dw.getDocumentDOM().getElementsByTagName('HTML')[0].outerHTML ;

    if (h.search(/<html[^>]*>/i)==-1 || h.search(/<head[^>]*/i) ==-1 ||
    h.search(/<body[^>]*/i) ==-1){ ...

    It is so interesting to me that the DW API returns a html element and
    then does not find "html" in the elements outerHtml.

    Similarly I have found that findElementsByTagName('UL'). e.g., will
    detect ULs in Included files, but if you then try to check the innerHTML
    of one of those UL nodes, DW returns instead the Include directive itself.

    Thanks so much for the solution.

    emichael brandt


    Phil wrote:
    > Maybe you could try with a regexp ?
    >
    > function runCmd(){
    > var leDOM = dw.getDocumentDOM();
    >
    > var html = leDOM.getElementsByTagName('html')[0];
    > var content = html.outerHTML;
    > var reg = /<html>/gi;
    >
    > if (reg.test(content)) {
    > alert('good');
    > // Process
    >
    > } else {
    > alert('bad');
    > return;
    > }
    >
    > window.close();
    > }
    >
    >
    >
    >> Does anyone know a way around this? Any way to properly detect that a
    >> document lacks any one or all of <html>, <body> and <head> tags?
    >>
    >> Thanks.
    >>
    >> emichael brandt
    >
    >
    E Michael Brandt Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139