简体   繁体   English

请解释一下这个 javascript 代码的作用

[英]Please explain me what this javascript code does

I have a javascript with the following code:我有一个带有以下代码的 javascript:

caburl="http://"+top.window.location.host+"/ims.cab";
cabver="1,1,1,5";
document.write("<object id='IMS' width=0 height=0 classid='CLSID:8246AC2B-4733-4964-A744-4BE60C6731D4' codebase='"+caburl+"#version="+cabver+"' style='display:none'></object>");

From the above lines, I can understand that the first line specifies the location of cab file.从上面几行可以理解,第一行指定了cab文件的位置。 Second Line specifies the cab file version.第二行指定 cab 文件版本。

Can anyone please explain me, what the third line does..which starts with Document.Write....谁能解释一下,第三行是做什么的……以 Document.Write 开头……

I dont have any knowledge of Javascript and want to convert the task performed by this javascript into my exe file.我对 Javascript 没有任何了解,并且想将此 javascript 执行的任务转换为我的 exe 文件。

Expecting a quick and positive response.期待快速和积极的回应。

The third line writes the generated string value to the page (concatenating strings with the values of the caburl and cabver variables).第三行将生成的字符串值写入页面(将字符串与caburlcabver变量的值连接起来)。

This adds an object element to the page with the values in the string.这会将object元素添加到带有字符串中值的页面。

From the value classid and the use of cab in the variable names, I would deduce this is an ActiveX component (so would only work on IE).从值classid和变量名中cab的使用,我会推断这是一个ActiveX组件(所以只能在 IE 上工作)。 This is normally used for installing the component on the client computer.这通常用于在客户端计算机上安装组件。

It joins a string together to make an html tag, and then using document.write appends it to the HTML document.它将一个字符串连接在一起形成一个 html 标记,然后使用 document.write 将其附加到 HTML 文档中。

The third line writes the string enclosed inside the write() function into the document being displayed in the browser.第三行将 write() function 中包含的字符串写入浏览器中显示的文档中。

Note that because of the style='display:none' text in the string, the <object> won't be visible in the browser.请注意,由于字符串中的style='display:none'文本, <object>在浏览器中将不可见。

The code will install Java CAB file called "ims.cab" hosted on some server.该代码将安装托管在某些服务器上的名为“ims.cab”的 Java CAB 文件。 See this question as well for reference: extract cab file and execute the exe file(inside the cab file) automatically请参阅此问题以供参考: 提取 cab 文件并自动执行 exe 文件(在 cab 文件中)

To do this with EXE of your own, you can take a look here: http://www.codeproject.com/KB/files/CABCompressExtract.aspx要使用您自己的 EXE 执行此操作,您可以在这里查看: http://www.codeproject.com/KB/files/CABCompressExtract.aspx

Let us know what language you intend to use (C++, C# etc) for further help.让我们知道您打算使用哪种语言(C++、C# 等)以获得进一步的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM