مرجع تخصصی برنامه نویسان

انجمن تخصصی برنامه نویسان فارسی زبان

کاربر سایت

rtr

عضویت از 1392/05/28

صدا زدن یک تابع از فایل جاوا اسکریپت

  • شنبه 4 اردیبهشت 1395
  • 17:46
تشکر میکنم

سلام دوستان من یک فایل جاوا اسکریپتی دارم چطوری می تونم یک تابع به نام show ی آن صدا بزنم.

محتویات فایل جاوا اسکریپت

  var HTML5Demos;
  var documentInfotest;
  
   
    (function (HTML5Demos) {
        var Dialogs;
        (function (Dialogs) {
            var DocumentPropertiesDlg = (function () {
                function DocumentPropertiesDlg() {
                             

                    // Create shortcuts for the dialog UI elements
                    //this.dialogUI = {
                    //    dialog:"#documentPropertiesDialog",
                    //    documentInfoTableBodyElement: "#documentInfo",
                    //    metadataTableBodyElement: "#metadata"
                    //};
                }

                    DocumentPropertiesDlg.prototype.show = function (document) {
                    alert('ok');
                    documentInfotest = new Array();
                    var x = document;
                    documentInfotest = x;
                    documentInfotest["URL"] = documentInfotest.uri;
                    documentInfotest["Document ID"] = documentInfotest.documentId;
                    alert(documentInfotest["Document ID"])





                    //  this.setup(document);
                    //   $(this.dialogUI.dialog).modal();
                };
                //DocumentPropertiesDlg.prototype.mytest= function () {
                //    alert('ggggggggggg');
                //  //  DocumentPropertiesDlg.prototype.show(document);
                //}
          
           
                DocumentPropertiesDlg.prototype.setup = function (document) {

                    // documentInfotest = new Array();
                    // Ensure that any open panels are closed before showing the dialog
                    $('#dialogPanelsContainer .in').collapse('hide');
                    documentInfo = new Array();
                    documentInfo["Document ID"] = document.documentId;
                    documentInfo["URL"] =document.uri;
                    documentInfo["MIME Type"] = document.mimeType;
                    documentInfo["Encrypted"] = document.isDecrypted ? "Yes" : "No";
                    if (document.annotations.annotationsUri != null) {
                   
                        documentInfo["Annotations URL"] = document.annotations.annotationsUri;
                    }
                    documentInfo["Pages"] = document.pages.length.toString();
                    if (document.pages.length > 0) {
                        var page = document.pages[0];
                        var pageSize = page.size;
                        var sizeInchdes = lt.LeadSizeD.create(pageSize.width / lt.Documents.Document.unitsPerInch, pageSize.height / lt.Documents.Document.unitsPerInch);
                        var sizePixels = document.sizeToPixels(pageSize);
                        documentInfo["Page size"] = sizeInchdes.width.toString() + " x " + sizeInchdes.height.toString() + " in (" + sizePixels.width.toString() + " x " + sizePixels.height.toString() + " px)";
                    }

                    //  documentInfotest = documentInfo;
                    this.generateDocumentInfoTable(documentInfo);
                    this.generateMetadataTable(document.metadata);
                    $(this.dialogUI.dialog).modal();
                };

           
                DocumentPropertiesDlg.prototype.generateDocumentInfoTable = function (documentInfo) {
                    var table = "";
                    for (var key in documentInfo) {
                        if (documentInfo.hasOwnProperty(key)) {
                            table += "<tr>";
                            table += "<td>" + key + "</td>";
                            table += "<td>" + documentInfo[key] + "</td>";
                            table += "</tr>";
                        }
                    }
                    $(this.dialogUI.documentInfoTableBodyElement).html(table);
                };
                DocumentPropertiesDlg.prototype.generateMetadataTable = function (metadata) {
                    var table = "";
                    for (var key in metadata) {
                        if (metadata.hasOwnProperty(key)) {
                            table += "<tr>";
                            table += "<td>" + key + "</td>";
                            table += "<td>" + metadata[key] + "</td>";
                            table += "</tr>";
                        }
                    }
                    $(this.dialogUI.metadataTableBodyElement).html(table);
                };
                return DocumentPropertiesDlg;
            }());
            Dialogs.DocumentPropertiesDlg = DocumentPropertiesDlg;
        })(Dialogs = HTML5Demos.Dialogs || (HTML5Demos.Dialogs = {}));
    })(HTML5Demos || (HTML5Demos = {}));

 

 

فایل html

<html>
<head>
<script type="text/javascript" src="Dialogs/DocumentPropertiesDlg.js"></script>
</head >

<body>
<script language="javascript">
//how call function show
</script>
</body>
</html>

 

پاسخ های این پرسش

تعداد پاسخ ها : 1 پاسخ
کاربر سایت

سجاد باقرزاده

عضویت از 1392/02/24

  • یکشنبه 5 اردیبهشت 1395
  • 08:57

من function show را داخل فایل اسکریپت ندیدم ولی بصورت کلی کافیست reffrence فایل اسکریپت را به صفحه بدهید و سپس نام function را به همراه پرانتز صدا بزنید برای مثال :

<script language="javascript">
show();
</script>

 

کاربرانی که از این پست تشکر کرده اند

هیچ کاربری تا کنون از این پست تشکر نکرده است

اگر نیاز به یک مشاور در زمینه طراحی سایت ، برنامه نویسی و بازاریابی الکترونیکی دارید

با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)