本文整理汇总了C#中IHTMLElement.insertAdjacentHTML方法的典型用法代码示例。如果您正苦于以下问题:C# IHTMLElement.insertAdjacentHTML方法的具体用法?C# IHTMLElement.insertAdjacentHTML怎么用?C# IHTMLElement.insertAdjacentHTML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHTMLElement
的用法示例。
在下文中一共展示了IHTMLElement.insertAdjacentHTML方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertHTML
/// <summary>
/// Inserts the given HTML code inside or outside of this Html element
/// There are 4 possible insert positions:
/// Outside-Before<TAG>Inside-Before InnerHTML Inside-After</TAG>Ouside-After
/// </summary>
/// <param name="elem"></param>
/// <param name="s_Html"></param>
/// <param name="b_AtBegin"></param>
/// <param name="b_Inside"></param>
public void InsertHTML(IHTMLElement elem, string s_Html, bool b_AtBegin, bool b_Inside)
{
if (elem == null)
return;
string bs_Where;
if (b_Inside)
{
if (b_AtBegin) bs_Where = "afterBegin";
else bs_Where = "beforeEnd";
}
else // Outside
{
if (b_AtBegin) bs_Where = "beforeBegin";
else bs_Where = "afterEnd";
}
elem.insertAdjacentHTML(bs_Where, s_Html);
}
示例2: NodoArbol
/// <summary>
/// Constructor del nodo
/// </summary>
/// <param name="padre">Nodo padre en el arbol de capitulos. Nulo si es la raiz</param>
/// <param name="nodo">Nodo HTML header correspondiente. Nulo si es la raiz</param>
public NodoArbol(NodoArbol padre, IHTMLElement nodo)
{
this.Padre = padre;
this.Nodo = nodo;
Hijos = new ArrayList();
Nivel = NivelNodo( nodo );
Archivo = "";
// Guardar la lista de los todos las referencias de este nodo ( nodos <A> con la propiedad "name")
listaANames = new ArrayList();
if( nodo != null )
{
IHTMLElementCollection col = (IHTMLElementCollection) nodo.children;
foreach( IHTMLElement hijo in col )
{
if (hijo is IHTMLAnchorElement)
{
// Remove empty spaces, because they will fail into the CHM.
// The anchors to this will be replace too after.
//listaANames.Add( ((IHTMLAnchorElement)hijo).name.Replace( " " , "" ) );
string processedName = ToSafeFilename( ((IHTMLAnchorElement)hijo).name );
listaANames.Add(processedName);
}
}
if( listaANames.Count == 0 )
{
// Si no tiene ningun nombre, darle uno artificial:
int numero = UltimoNumeroAname++;
string nombreNodo = "NODO" + numero.ToString().Trim();
string tagA = "<a name=\"" + nombreNodo + "\">";
nodo.insertAdjacentHTML( "afterBegin" , tagA );
listaANames.Add( nombreNodo );
}
}
}
示例3: NodoArbol
/// <summary>
/// Tree section node constructor
/// </summary>
/// <param name="parent">Parent section of the section to create. null if the node to create is the root section.</param>
/// <param name="node">HTML header tag for this section</param>
/// <param name="ui">Application log. It can be null</param>
public NodoArbol(NodoArbol parent, IHTMLElement node, UserInterface ui)
{
this.Padre = parent;
this.Nodo = node;
Hijos = new ArrayList();
Nivel = NivelNodo( node );
Archivo = "";
// Guardar la lista de los todos las referencias de este nodo ( nodos <A> con la propiedad "name")
listaANames = new ArrayList();
if( node != null )
{
IHTMLElementCollection col = (IHTMLElementCollection) node.children;
foreach( IHTMLElement hijo in col )
{
if (hijo is IHTMLAnchorElement)
{
// Remove empty spaces, because they will fail into the CHM.
// The anchors to this will be replace too after.
//listaANames.Add( ((IHTMLAnchorElement)hijo).name.Replace( " " , "" ) );
string processedName = ToSafeFilename( ((IHTMLAnchorElement)hijo).name );
if (processedName == null || processedName.Trim() == "")
// It seems on HTML 5 and XHTML <a id="foo"> is used...
processedName = ToSafeFilename( hijo.id );
if( processedName != null && processedName.Trim() != "" )
listaANames.Add(processedName);
}
}
if( listaANames.Count == 0 )
{
// Si no tiene ningun nombre, darle uno artificial:
int numero = UltimoNumeroAname++;
string nombreNodo = "NODO" + numero.ToString().Trim();
string tagA = "<a name=\"" + nombreNodo + "\">";
try
{
node.insertAdjacentHTML("afterBegin", tagA);
listaANames.Add(nombreNodo);
}
catch (Exception ex)
{
if( ui != null )
ui.log( new Exception("There was an error trying to add the tag " +
tagA + " to the node " + node.outerHTML + " (wrong HTML syntax?). If " +
"the source document is HTML, try to add manually an <a> tag manually. " +
"The application needs a node of this kind on each section title " +
"to make links to point it", ex ) );
}
}
}
}