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)
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...
|
|
|
|
TKS
-
Total Posts
:
188
- Scores: 0
-
Reward points
:
0
- Joined: 5/16/2008
-
Status: offline
|
RE: DOM - RemoveChild Save to file >> .html instead of .xml ?
Saturday, May 24, 2008 4:17 PM
( permalink)
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
|
|
|
|
TKS
-
Total Posts
:
188
- Scores: 0
-
Reward points
:
0
- Joined: 5/16/2008
-
Status: offline
|
RE: DOM - RemoveChild Save to file >> .html instead of .xml ?
Sunday, May 25, 2008 11:19 AM
( permalink)
LINK ^^^ Looks like Regular Expressions and Patterns may be a way of getting this done...
|
|
|
|
TKS
-
Total Posts
:
188
- Scores: 0
-
Reward points
:
0
- Joined: 5/16/2008
-
Status: offline
|
RE: DOM - RemoveChild Save to file >> .html instead of .xml ?
Sunday, May 25, 2008 12:53 PM
( permalink)
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
|
|
|
|
TKS
-
Total Posts
:
188
- Scores: 0
-
Reward points
:
0
- Joined: 5/16/2008
-
Status: offline
|
RE: DOM - RemoveChild Save to file >> .html instead of .xml ?
Wednesday, May 28, 2008 5:12 PM
( permalink)
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
|
|
|
|