DOM - RemoveChild Save to file >> .html instead of .xml ?

Author Message
TKS

  • Total Posts : 188
  • Scores: 0
  • Reward points : 0
  • Joined: 5/16/2008
  • Status: offline
DOM - RemoveChild Save to file >> .html instead of .xml ? Saturday, May 24, 2008 4:16 PM (permalink)
0
Today is officially my first day of looking at DOM, and this was what I came up with. It's rough, but it works to an extent:

 <html>
     <head>
         <script type="text/javascript">
             function test2(val) {
             if (document.getElementById && document.createElement)
             {
             node = document.getElementById('7607236ID');
             node.removeChild(node.childNodes[0]);
             }
             else alert('Your browser doesn\'t support the Level 1 DOM');
             }
         </script>
     </head>
     <body>
         <span style="font-family:Verdana,sans-serif;" id="7607236ID">Comment: Text here</span>
         <a href="javascript:test2()">Delete Comment</a>
         <br>
         <a href="http://www.quirksmode.org/dom/cms.html" title="It's definately gonna take me some time figuring out the edit part, but this looks like a good place to start...">Edit Comment</a>
     </body>
 </html>
 


How can I get the DOM to save this removechild to file permanantly?-

If you already understand how to fix this then you don't need to read my following explaination:

Explaination: This is an embedded iframe on my original .hta document (application=yes). The original hta outputs data to the iframe via a textarea and additional variables- Output: (a) span element with random ID; (b) a href element to call JavaScript; (c) and the JavaScript used to remove the span with ID=Rnd()... but this attempt to "delete" the span, instead temporarily removes it from display... the idea is to open .html, delete span and and all of it's childnodes... all... then save... then the iframe refreshes and renders what appears to be a deleted commented...
 
#1
    TKS

    • Total Posts : 188
    • Scores: 0
    • Reward points : 0
    • Joined: 5/16/2008
    • Status: offline
    RE: DOM - RemoveChild Save to file &gt;&gt; .html instead of .xml ? Saturday, May 24, 2008 4:17 PM (permalink)
    0
    By the way, please keep in mind that I'm new to DOM. So if you do something, it would help alot if you said why.

    Thanks in advance.

    -TKS
     
    #2
      TKS

      • Total Posts : 188
      • Scores: 0
      • Reward points : 0
      • Joined: 5/16/2008
      • Status: offline
      RE: DOM - RemoveChild Save to file &gt;&gt; .html instead of .xml ? Sunday, May 25, 2008 11:19 AM (permalink)
      0
      LINK

      ^^^ Looks like Regular Expressions and Patterns may be a way of getting this done...
       
      #3
        TKS

        • Total Posts : 188
        • Scores: 0
        • Reward points : 0
        • Joined: 5/16/2008
        • Status: offline
        RE: DOM - RemoveChild Save to file &gt;&gt; .html instead of .xml ? Sunday, May 25, 2008 12:53 PM (permalink)
        0
         Const ForReading=1, ForWriting=2, ForAppending=8
         Set objFSO = CreateObject("Scripting.FileSystemObject")
         Set objFile = objFSO.OpenTextFile("Test.txt", ForAppending, True)
         
         foo = "<title>some crazy title</title>" 'your html text
         Set re = new RegExp 'new regular expressions object
         re.IgnoreCase = true 'ignore case when matching
         re.Global = false 'stop after first match
         re.Pattern = "<title>(.*)?</title>" 'pattern to match
         set matches = re.Execute(foo) 'match with contents of foo variable
         objFile.Write matches.item(0).submatches(0) 'contents of title tag 
         


        ^^^ This code writes the text between tags: "<title>" and "</title>" to file...

        So, I'm guessing there's indeed a way of deleting text between those tags too...

        Almost there...

        -TKS
         
        #4
          TKS

          • Total Posts : 188
          • Scores: 0
          • Reward points : 0
          • Joined: 5/16/2008
          • Status: offline
          RE: DOM - RemoveChild Save to file &gt;&gt; .html instead of .xml ? Wednesday, May 28, 2008 5:12 PM (permalink)
          0
          Figured the problem out aided by TNO:

          <script language="JavaScript">
           function insertAtCursor( myValue) {
           myField = top.document.getElementById("testID");
           //IE support
           if (top.document.selection) {
           myField.focus();
           sel = top.document.selection.createRange();
           sel.text = myValue;
           }
           //MOZILLA/NETSCAPE support
           else if (myField.selectionStart || myField.selectionStart == '0') {
           var startPos = myField.selectionStart;
           var endPos = myField.selectionEnd;
           myField.value = myField.value.substring(0, startPos)
           + myValue
           + myField.value.substring(endPos, myField.value.length);
           } else {
           myField.value += myValue;
           }
           }
           </script>
           


          ^^^ Tagets top.parent.document textarea from an iframe perfectly.

          -TKS
           
          #5

            Online Bookmarks Sharing: Share/Bookmark

            Jump to:

            Current active users

            There are 0 members and 1 guests.

            Icon Legend and Permission

            • New Messages
            • No New Messages
            • Hot Topic w/ New Messages
            • Hot Topic w/o New Messages
            • Locked w/ New Messages
            • Locked w/o New Messages
            • Read Message
            • Post New Thread
            • Reply to message
            • Post New Poll
            • Submit Vote
            • Post reward post
            • Delete my own posts
            • Delete my own threads
            • Rate post

            2000-2012 ASPPlayground.NET Forum Version 3.9