-1

我正在创建一个谷歌浏览器扩展并且我遇到了一些麻烦。我得到了一个目标文件,它代表了一个表格和他的动作。我的问题是,在我使用该对象后,有些东西会中断,并且脚本文件上没有代码运行。

这是表单对象文件:

/// <reference path="../Jquery1.6_vsdoc/ChromeExtenVSdoc.js" />
/// <reference path="../Jquery1.6_vsdoc/jquery-vsdoc.js" />

function FormInputObject() {

this.BusinessName = "";
this.ShortDesc = "";
this.LongDesc = "";
this.Location = "";
this.ContactName = "";
this.Telephone = "";
this.CellPhone = "";
this.FaxNumber = ""
this.Adress = "";
this.City = "";
this.BusinessEmail = "";
this.WebSiteAdress = "";
this.Keywords = "";

this.PrivateName = "";
this.PrivateTelepone = "";
this.PrivateEmail = "";


//get user data from the INPUT html
this.GetInputFormDocument = function (document) {

    this.BusinessName  = $("name");
    this.ShortDesc     = $("descriplittle");
    this.LongDesc      = $("descrip");
    this.Location      = $("area");
    this.ContactName   = $("contactman");
    this.CellPhone     = $("pelephone");
    this.FaxNumber     = $("fax");
    this.Adress        = $("adr");
    this.City          = $("city");
    this.BusinessEmail = $("email");
    this.WebSiteAdress = $("www");
    this.Keywords      = $("keywords");

    this.PrivateName     =  $("firstname1");
    this.PrivateTelepone =  $("phone1");
    this.PrivateEmail    =  $("email1");
}

this.ClearForm = function (document) {


    this.ShortDesc         .text("");
    this.LongDesc          .text("");
    this.Location          .text("");
    this.ContactName       .text("");
    this.CellPhone         .text("");
    this.FaxNumber         .text("");
    this.Adress            .text("");
    this.City              .text("");
    this.BusinessEmail     .text("");
    this.WebSiteAdress     .text("");
    this.Keywords          .text("");

    this.PrivateName       .text("");
    this.PrivateTelepone   .text("");
    this.PrivateEmail      .text("");
}



  //sending only the object fields
   this.sendFormFields = function (command) {
        chrome.extension.sendRequest(null,
            {
                input          : command            ,
                BusinessName   : this.BusinessName  ,
                ShortDesc      : this.ShortDesc     ,
                LongDesc       : this.LongDesc      ,
                Location       : this.Location      ,
                ContactName    : this.ContactName   ,
                CellPhone      : this.CellPhone     ,
                FaxNumber      : this.FaxNumber     ,
                Adress         : this.Adress        ,
                City           : this.City          ,
                BusinessEmail  : this.BusinessEmail ,
                WebSiteAdress  : this.WebSiteAdress ,
                Keywords       : this.Keywords      ,

                PrivateName       : this.PrivateName    ,   
                PrivateTelepone   : this.PrivateTelepone,
                PrivateEmail      : this.PrivateEmail
            },
             function (response) {

             });

   }

    //sending all of the object
   this.sendTheFormObject = function () {
       chrome.extension.sendRequest(null,
           {
               FormInputObject: this
           },
           function (response) {

           });
   }
}

这是我使用该对象的脚本文件:

/// <reference path="../ChromeExtenVSdoc.js" />
/// <reference path="../Jquery1.6_vsdoc/jquery-vsdoc.js" />
/// <reference path="FormInputObject.js" />

//if i comment this line out, there is no problems and the alerts
//i call in the file run fine
var formInput = new FormInputObject();

$(document).ready(function () {


$("#sendData").click(null, function () {

    formInput.GetInputFormDocument(document);

    formInput.sendFormFields("justFillOutFourm");

});

$("#clearForm").click(null, function () {
    formInput.ClearForm(document);
    alert("asdf");

});
alert("asdf");

});

我确定我的对象有问题,但我不知道它是什么。(对不起我的英语不好)

编辑:这是如何引用 html 上的文件:

    <head>
    <title></title>
     <script src="../Jquery1.6_vsdoc/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="input_page.js" type="text/javascript"></script>
   </head>
4

1 回答 1

1

var formInput = new FormInputObject();文件准备好后移动。还要确保您包含jquery.js,并且在任何其他需要它的 JS 之前包含它。

于 2013-04-13T13:53:15.553 回答