RetroZilla/extensions/xmlterm/ui/content/insertest.html

40 lines
1.8 KiB
HTML
Raw Normal View History

2015-10-21 05:03:22 +02:00
<!-- insertest.html: Tests insertion HTML fragments -->
<html><head>
<script language="JavaScript">
function runTest(aEvent) {
dump("runTest:\n");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var domselection = window._content.getSelection();
if (domselection && !domselection.isCollapsed &&
domselection.containsNode(aEvent.target,false))
{
var privateSelection = domselection.QueryInterface(Components.interfaces.nsISelectionPrivate);
dump("privatesel"+privateSelection+"\n");
var sel = privateSelection.QueryInterface(Components.interfaces.nsISelection);
dump("sel="+sel+"\n");
var range = sel.getRangeAt(0);
dump("range="+range+"\n");
var htmlFrag = '<SPAN onclick="' + "dump('ONCLICKED!');" + '"> <B>HTML fragment</B> </SPAN>';
var htmlFrag2 = '<DIV class="entry" name="entry" id="entry3"> <DIV class="output" name="output" id="output3"> <TABLE frame="none" border="0"> <COLGROUP colspan="5" width="1*"></COLGROUP> <TBODY> <TR> <TD> <SPAN class="directory" onclick="dump(event);"> chrome </SPAN> </TD> <TD> <SPAN class="plainfile" onclick="dump(event);"> install.js </SPAN> </TD> </TR> </TBODY> </TABLE> </DIV> </DIV>'
dump(htmlFrag2+"\n");
var docFrag = range.createContextualFragment(htmlFrag2);
dump("docFrag = "+docFrag+"\n");
dump("docFrag.firstChild = "+docFrag.firstChild+"\n");
var bodyElement = document.getElementById("bodyEl");
dump("bodyElement = "+bodyElement+"\n");
bodyElement.appendChild(docFrag.firstChild);
}
}
</script>
</head><body id="bodyEl">
<SPAN class="test" onclick="return runTest(event);">INSERT FRAGMENT TEST<SPAN>
</body></html>