mirror of
https://github.com/rn10950/RetroZilla.git
synced 2024-11-14 03:30:17 +01:00
40 lines
1.8 KiB
HTML
40 lines
1.8 KiB
HTML
<!-- 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>
|