creating new command, how to select entire sourcecode

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

  1. #1

    Default creating new command, how to select entire sourcecode

    (i posted this same question on the general discussion forum a couple of hours
    ago, but this is a better place for it)

    Hi,
    I often have to do a lot of find-and-replace actions on sites i'm building,
    and i want to put all of these standard actions in a custom command in
    dreamweaver.

    I've built a nice little gui, but i'm wrestling with the javascript, i've
    tried expanding on the 'Change Case' tutorial file, but this file only changes
    the values within a certain element.
    What i want is that i can get the entire sourcecode of a html file into one
    single variable, so i can work my magic on that variable, and then to put the
    entire thing back into the file.

    I've attached the sourcecode, as you can see i've stripped it of just about
    anything i think i don't need until i get past the current problem.


    Can anyone point me in the right direction?
    thanx in advance,

    Casper de Groot
    the Netherlands


    attached code:

    // JavaScript Document

    function commandButtons() {
    return new Array("OK", "action()", "Cancel", "window.close()");
    }

    function action(){

    //get the current sourcecode
    var theDOM = dw.getDocumentDOM();
    var theWholeDoc = theDOM.outerHTML;

    alert (theWholeDoc); //show it

    //change the sourcecode
    theWholeDoc = "<html><body>this is the new sourcecode</body></html>";

    //write it back to the file
    theDOM.outerHTML = theWholeDoc;

    //close the gui
    window.close(); // close extension UI
    }

    Koesper Guest

  2. Similar Questions and Discussions

    1. Dislay mySql version from a SELECT command?
      Is there a way to display the mySql version number from a SELECT command? I need to check on a server where I have limited access. Thanks
    2. Improve SELECT command
      Dear MySQL-ians, I perform a SELECT on my database, but it takes over a minute for every run. I have to run it over 10000 times (with different...
    3. Select Entire datagrid Row when down & up key is pressed
      Hi, How to make the entire row in datagrid to be selected by using Up & Down arrow key? Thanks Edward
    4. Creating PDF via "Get Entire Site" but not breaking long pages
      Hello, I am using Acrobat v5 and need to generate pdf files from entire sites. Everything works smoothly except one thing. Vertically tall web...
    5. Command to Select Mask won't work in F-MX
      Hello! I have a script I created and used in Fireworks 4, and have tried to use without success in MX. The script used a command that selected an...
  3. #2

    Default Re: creating new command, how to select entire sourcecode

    > var theDOM = dw.getDocumentDOM();
    > var theWholeDoc = theDOM.outerHTML;
    Try this :

    var theDOM = dw.getDocumentDOM();
    var theHTML = theDOM.getElementsByTagName('html')[0];
    var theWholeDoc = theHTML.outerHTML;

    alert (theWholeDoc); //show it

    theWholeDoc = "<html><body>this is the new sourcecode</body></html>";

    //write it back to the file
    theHTML.outerHTML = theWholeDoc;




    Phil Guest

  4. #3

    Default Re: creating new command, how to select entiresourcecode

    Thanx, i got it up and running with your help.
    Koesper 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