Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在Internet explorer扩展开发(BHO)中运行jQuery文件_Jquery_Asp.net_Asp.net Mvc_Internet Explorer_Bho - Fatal编程技术网

无法在Internet explorer扩展开发(BHO)中运行jQuery文件

无法在Internet explorer扩展开发(BHO)中运行jQuery文件,jquery,asp.net,asp.net-mvc,internet-explorer,bho,Jquery,Asp.net,Asp.net Mvc,Internet Explorer,Bho,试图在我的BHO文件中包含jQuery CDN文件…当项目生成并向regasm注册时,它会显示警报消息,但jQuery文件未加载并显示错误 下面是我的代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using SHDocVw; using mshtml; using System.Runtime.InteropServices; using Microsoft.Wi

试图在我的BHO文件中包含jQuery CDN文件…当项目生成并向regasm注册时,它会显示警报消息,但jQuery文件未加载并显示错误

下面是我的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SHDocVw;
using mshtml;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Windows.Forms;

namespace Greyhound.BHO
{

[
    ComVisible(true),
    Guid("8a194578-81ea-4850-9911-13ba2d71efbd"),
    ClassInterface(ClassInterfaceType.None)
]

public class BHO:IObjectWithSite
{
    SHDocVw.WebBrowser webBrowser;

    public static string BHOKEYNAME =
      "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects";

    [ComRegisterFunction]
    public static void RegisterBHO(Type type)
    {
        RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BHOKEYNAME, true);

        if (registryKey == null)
            registryKey = Registry.LocalMachine.CreateSubKey(BHOKEYNAME);

        string guid = type.GUID.ToString("B");
        RegistryKey ourKey = registryKey.OpenSubKey(guid);

        if (ourKey == null)
            ourKey = registryKey.CreateSubKey(guid);

        ourKey.SetValue("Alright", 1);
        registryKey.Close();
        ourKey.Close();
    }

    [ComUnregisterFunction]
    public static void UnregisterBHO(Type type)
    {
        RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BHOKEYNAME, true);
        string guid = type.GUID.ToString("B");

        if (registryKey != null)
            registryKey.DeleteSubKey(guid, false);
    }

    public void OnDocumentComplete(object pDisp, ref object URL)
    {
        IHTMLDocument2 doc = (IHTMLDocument2)webBrowser.Document;
        doc.parentWindow.execScript("var d=window.document,s=d.createElement('script'),h=d.getElementsByTagName('body')[0];s.src='http://code.jquery.com/jquery-1.11.1.min.js';h.appendChild(s);");
        doc.parentWindow.execScript("alert('hello');","JScript");
    }

    public int SetSite(object site)
    {
        if (site != null)
        {
            webBrowser = (SHDocVw.WebBrowser)site;
            webBrowser.DocumentComplete +=
              new DWebBrowserEvents2_DocumentCompleteEventHandler(
              this.OnDocumentComplete);
        }
        else
        {
            webBrowser.DocumentComplete -=
              new DWebBrowserEvents2_DocumentCompleteEventHandler(
              this.OnDocumentComplete);
            webBrowser = null;
        }

        return 0;
    }

    public int GetSite(ref Guid guid, out IntPtr ppvSite)
    {
        IntPtr punk = Marshal.GetIUnknownForObject(webBrowser);
        int hr = Marshal.QueryInterface(punk, ref guid, out ppvSite);
        Marshal.Release(punk);
        return hr;
    }

}
}
下面是遇到的错误:

错误是

大宗报价

对象不支持属性或方法“getElementsByClassName”

大宗报价


请让我知道我在哪里犯了错误,因为我是BHO的新手。

我能在这里嗅到aSp.NeT \??@jQueryAngryBird:是的:)@Adi,那么aditya,你应该把它添加为标签,所以很多aSp.NeT中有天赋的用户会来这里解决你的问题