CN103902534B - A method and apparatus for triggering the local program page operation - Google Patents

A method and apparatus for triggering the local program page operation Download PDF

Info

Publication number
CN103902534B
CN103902534B CN 201210568093 CN201210568093A CN103902534B CN 103902534 B CN103902534 B CN 103902534B CN 201210568093 CN201210568093 CN 201210568093 CN 201210568093 A CN201210568093 A CN 201210568093A CN 103902534 B CN103902534 B CN 103902534B
Authority
CN
Grant status
Grant
Patent type
Prior art keywords
local
operation
program
address
access request
Prior art date
Application number
CN 201210568093
Other languages
Chinese (zh)
Other versions
CN103902534A (en )
Inventor
刘昊
Original Assignee
联想(北京)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Grant date

Links

Abstract

本发明公开了一种网页程序触发本地操作的方法和装置,属于互联网技术领域。 The present invention discloses a method and apparatus for operating a web trigger a local program, belonging to Internet technology. 所述方法包括:网页程序中设置有包含连接本地程序的HTTP链接的JavaScript代码;所述本地程序接收浏览器在执行所述JavaScript代码的过程中根据所述JavaScri pt代码中的所述HTTP链接发送的地址访问请求,所述地址访问请求中携带有所述JavaScript代码中记录的本地操作标识;所述本地程序根据所述本地操作标识,在所述本地设备中执行相应的本地操作。 Said method comprising: Web applications is provided comprising a JavaScript code HTTP link connecting the local program; the local browser program receives during execution of the JavaScript code is transmitted according to the code JavaScri pt HTTP link address of the access request, the access request carries an address of the local operation JavaScript recorded identification code; said local identification procedure according to the local operation, performed at the local operation of the respective local device. 采用本发明,可以提高网页程序触发本地操作的过程的通用性。 According to the present invention can improve the versatility of the process page program triggers a local operation.

Description

一种网页程序触发本地操作的方法和装置 A method and apparatus for triggering the local program page operation

技术领域 FIELD

[0001] 本发明涉及互联网技术领域,特别涉及一种网页程序触发本地操作的方法和装置。 [0001] The present invention relates to the field of Internet technologies, and particularly relates to a method and apparatus for triggering the local program page operation.

背景技术 Background technique

[0002] 随着浏览器技术的不断发展,网页程序能够实现越来越多终端本地程序(或称桌面程序)能够实现的功能,如数据管理、文档编辑等。 [0002] With the development of browser technology, Web applications can be realized more and more local terminal program (also known as desktop program) to achieve functions such as data management, document editing. 然而,网页程序对数据的管理和对文档的编辑等操作都是在网络侧的服务器中实现的,基于网络安全的考虑,网页程序并没有进行本地操作(对设备的本地软硬件资源进行相关操作)的权限,网页程序既不能向本地发送数据(或消息),也不能从本地读取数据。 However, the page program data management and editing of documents and other operations are implemented in the server side of the network, the network-based security considerations, the page program and no local operation (hardware and software resources for local equipment related operations ) access, web applications neither the transmission data (or message) to the local, nor to read data from the local.

[0003] 针对该问题,现有技术中提出了浏览器插件技术,可以在终端为浏览器程序安装相应的插件,例如IE (Internet Explorer,互联网浏览器)中应用的ActiveX (—个开放式的创建程序集成和内容的集成平台)插件,浏览器提供相应的API (Application Prog ramming Interface,应用程序编程接口)与插件进行交互。 [0003] To solve this problem, the prior art proposes a browser plug-in technology, can install an insert for the browser program in the terminal, e.g. IE (Internet Explorer, Internet browser) application ActiveX (- x open integration platform to create integrated programs and content) plug-in, the browser provides the appropriate API (application Prog ramming Interface, application programming Interface) to interact with the plug-ins. 当网页程序需要触发本地操作时,可以通过浏览器调用相应的API,通过向插件发送本地操作请求,并由插件根据本地操作请求完成相应的操作(如运行某本地应用程序等)。 When the program needs to trigger the local web operation, you can call the corresponding API browser by sending a request to the plug local operation by the local operation of the plug-in complete the corresponding request according to the operation (e.g., running a local application, etc.).

[0004] 在实现本发明的过程中,发明人发现现有技术至少存在以下问题: [0004] During the implementation of the present invention, the inventors found that the prior art has at least the following problems:

[0005] 现有技术中,不同内核的浏览器(如IE、Firefox (火狐)浏览器等)所提供的API是不同的,所以,通过插件触发本地操作的方式通用性差,对于相同的功能,需要针对不同的浏览器开发不同的插件,需要对不同的插件进行加载,造成资源浪费。 [0005] In the prior art, the API of different kernels browser (such as IE, Firefox (Firefox) browser, etc.) provided are different, so that, by way of plug trigger a local operation poor versatility, and the same functions, different needs for different browser plug-in development, need to be loaded for different plug-ins, a waste of resources.

发明内容 SUMMARY

[0006] 为了解决现有技术的问题,本发明实施例提供了一种网页程序触发本地操作的方法和装置,以提高网页程序触发本地操作的过程的通用性。 [0006] In order to solve the problems of the prior art, the present invention provides a method and apparatus for triggering the local program page operation, the page program triggers to enhance the versatility of the process of local operations. 所述技术方案如下: The technical solutions are as follows:

[0007] 一方面,提供了一种网页程序触发本地操作的方法,网页程序中设置有包含连接本地程序的HTTP链接的JavaScript代码,所述方法包括: [0007] In one aspect, there is provided a method of triggering a local page program operation, the program is provided with a web page JavaScript code program comprises an HTTP connection to the local link, the method comprising:

[0008] 所述本地程序接收浏览器在执行所述JavaScript代码的过程中根据所述JavaScript代码中的所述HTTP链接发送的地址访问请求,所述地址访问请求中携带有所述JavaScript代码中记录的本地操作标识; [0008] The local browser program receives during execution of the JavaScript code in the address of the access request HTTP link JavaScript code transmitted, the access request carries the address of the JavaScript code is recorded the local operation identifier;

[0009] 所述本地程序根据所述本地操作标识,在所述本地设备中执行相应的本地操作。 [0009] The local operation procedure according to the local identifier, the local operation performed in the respective local device.

[0010] 优选的,所述本地操作标识具体为所述HTTP链接中的路径标识; [0010] Preferably, the identifier identifies a specific operation to local HTTP link in the path;

[0011] 所述本地程序中记录有路径标识与本地操作的对应关系; [0011] The local program is recorded in a corresponding relationship with the local operation of the path identifier;

[0012] 所述本地程序根据所述本地操作标识,在所述本地设备中执行相应的本地操作, 具体为:所述本地程序根据记录的路径标识与本地操作的对应关系,确定所述地址访问请求中的路径标识对应的本地操作;所述本地程序在所述本地设备中执行该本地操作。 [0012] The local operation procedure according to the local identifier, the local operation performed in the respective local device, specifically: the program according to the local corresponding relation with the path identifier of the local operation record, to determine the address access the local route request corresponding to an operation identifier; the local program executing on the local operation of the local device.

[0013] 优选的,所述方法还包括: [0013] Preferably, the method further comprising:

[0014] 所述本地程序向所述浏览器发送JavaScript代码形式的答复洎息,所还合炅伯芯、 中携带有所述本地操作的执行结果。 [0014] sending the local program to the browser in the form of JavaScript code JI reply message, the core also co-Gui primary, carries the execution result of which the local operation.

[0015] 优选的,所述本地程序向所述浏览器发送JavaScript代码形式的答复消息之后, 还包括: [0015] Preferably, after sending the local program JavaScript code in the form of a reply message to the browser, further comprising:

[0016] 所述浏览器获取所述答复消息中携带的所述本地操作的执行结果; [0016] The browser acquires an execution result of the local operation message carries the reply;

[0017] 所述浏览器对所述执行结果进行显示。 The [0017] Results of the browser for display.

[0018] 优选的,所述HTTP链接中的域名具体为本机域名,所述HTTP链接中的端口号具体为本地设备中系统分配给所述本地程序的端口号。 [0018] Preferably, the HTTP link specific native domain name, port number of the port number in the HTTP link to the local device specifically allocated to the local system program.

[0019] 优选的,所述地址访问请求中还携带有所述JavaScript代码中记录的密钥; [0019] Preferably, the address access request further carries the JavaScript code recorded in the key;

[0020] 所述本地程序根据所述本地操作标识,在所述本地设备中执行相应的本地操作, 具体为:所述本地程序将所述地址访问请求中携带的密钥与所述本地程序中存储的密钥进行对比,如果匹配,则根据所述本地操作标识,在所述本地设备中执行相应的本地操作。 [0020] The local operation procedure according to the local identifier, the local device performs in a respective local operation, in particular: the local program key with the local address of the program carried in the access request comparing the stored key, if a match is identified according to the local operation, performed at the local operation of the respective local device.

[0021] 另一方面,提供了一种网页程序触发本地操作的装置,网页程序中设置有包含连接本地程序的HTTP链接的JavaScript代码,所述装置包括: [0021] In another aspect, there is provided an apparatus for triggering a local page program operation, the program is provided with a web page JavaScript code program comprises an HTTP connection to the local link, the apparatus comprising:

[0022] 接收模块,用于接收浏览器在执行所述JavaScript代码的过程中根据所述JavaScript代码中的所述HTTP链接发送的地址访问请求,所述地址访问请求中携带有所述JavaScript代码中记录的本地操作标识; Process [0022] a receiving module, configured to receive the browser execute JavaScript code in the address of the access request from the HTTP link JavaScript code transmitted, the access request carries the address of the JavaScript code local operation record identifier;

[0023] 执行模块,用于根据所述本地操作标识,在所述本地设备中执行相应的本地操作。 [0023] The execution module, according to said local identification operation, performed at the local operation corresponding local devices.

[0024] 优选的,所述本地操作标识具体为所述HTTP链接中的路径标识; [0024] Preferably, the identifier identifies a specific operation to local HTTP link in the path;

[0025] 所述执行模块中记录有路径标识与本地操作的对应关系; The module is recorded corresponding relationship with the local operation path identifier [0025] The execution;

[0026] 所述执行模块,具体用于:根据记录的路径标识与本地操作的对应关系,确定所述地址访问请求中的路径标识对应的本地操作;在所述本地设备中执行该本地操作。 [0026] The execution module is configured to: according to a correspondence relationship between the path identifier and the local operation record, to determine the local address of the operation path identifier corresponding to the access request; performing the local operation in the local device.

[0027]优选的,所述执行模块,还用于: [0027] Preferably, the execution module is further configured to:

[0028] 向所述浏览器发送JavaScript代码形式的答复消息,所述答复消息中携带有所述本地操作的执行结果。 [0028] JavaScript code sent to the browser in the form of a reply message, the reply message carries an execution result of the local operation.

[0029] 优选的,所述HTTP链接中的域名具体为本机域名,所述HTTP链接中的端口号具体为本地设备中系统分配给所述本地程序的端口号。 [0029] Preferably, the HTTP link specific native domain name, port number of the port number in the HTTP link to the local device specifically allocated to the local system program.

[0030] 优选的,所述地址访问请求中还携带有所述JavaScript代码中记录的密钥; [0030] Preferably, the address access request further carries the JavaScript code recorded in the key;

[0031] 所述执行模块,具体用于:将所述地址访问请求中携带的密钥与所述本地程序中存储的密钥进行对比,如果匹配,则根据所述本地操作标识,在所述本地设备中执行相应的本地操作。 [0031] The execution module is configured to: the program key with the local address of the access request key stored in the comparison, if a match is identified according to the local operation, the performing a local operation corresponding local devices.

[0032]本发明实施例提供的技术方案带来的有益效果是: [0032] Embodiments of the invention provide a technical solution is beneficial effects:

[0033] 本发明实施例中,浏览器在执行网页程序的JavaScript代码时,通过HTTP (Hyper Text Transport Protocol,超文本传输协议)方式向本地程序发送地址访问请求,并通过地址访问请求中的本地操作标识指示本地程序执行相应的本地操作。 [0033] The embodiments of the present invention, the browser when the execution of the web application JavaScript code, sends an address access request to the local program via HTTP (Hyper Text Transport Protocol, Hypertext Transfer Protocol) mode, and the address access request is a local operation identifier indicates the corresponding local local program execution operation. 因为,不同内核的浏览器通过HTTP方式向本地程序发送地址访问请求,是没有区别的,所以,此方法可以提高网页程序触发本地操作的过程的通用性。 Because different kernel browser to send HTTP to local programs to address access request, there is no difference, therefore, this method can increase the versatility of web applications trigger local operation of the process.

附图说明 BRIEF DESCRIPTION

[0034] 为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。 [0034] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, as briefly described in the introduction to the accompanying drawings required for use in describing the embodiments. Apparently, the drawings in the following description are only some of the present invention. embodiments, those of ordinary skill in the art is concerned, without creative efforts, can derive from these drawings other drawings.

[0035] 图1是本发明实施例提供的网页程序触发本地操作的方法流程图; [0035] FIG. 1 is a web application according to an embodiment of the present invention a flowchart of a method to trigger a local operation;

[0036] 图2是本发明实施例提供的网页程序触发本地操作的装置结构示意图。 [0036] FIG. 2 is a page program according to an embodiment of the present invention means a schematic structure of a local operation is triggered.

具体实施方式 detailed description

[0037] 为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。 [0037] To make the objectives, technical solutions, and advantages of the present invention will become apparent in conjunction with the accompanying drawings of the following embodiments of the present invention will be described in further detail.

[0038] 实施例一 [0038] Example a

[0039] 本发明实施例提供了一种网页程序触发本地操作的方法。 Embodiment [0039] The present invention provides a method to trigger a local program page operation. 在该方法中,网页程序中设置有包含连接本地程序的HTTP链接的JavaScript^—种基于对象和事件驱动并具有相对安全性的客户端脚本语言)代码。 In this method, the page program is provided with a connection to the local program contains JavaScript ^ HTTP link - the kind of object-based and event driven and has the relative safety of client-side scripting language) code. 如图1所示,该方法的处理流程可以具体包括如下步骤: As shown in FIG. 1, a process flow of the method may includes the following steps:

[0040] 步骤101,本地程序接收浏览器在执行上述JavaScript代码的过程中根据该JavaScript代码中的该HTTP链接发送的地址访问请求。 [0040] Step 101, the local browser program receives the request during execution of the above-described JavaScript code to access the HTTP address link to the JavaScript code transmitted. 其中,该地址访问请求中携带有该JavaScript代码中记录的本地操作标识。 Wherein the address access request carries the identifier of the local operation of JavaScript code recorded.

[0041] 步骤102,本地程序根据接收到的本地操作标识,在本地设备中执行相应的本地操作。 [0041] Step 102, a local program according to the local operator identifier received, performs a corresponding local operating in the local device.

[0042] 本发明实施例中,浏览器在执行网页程序的JavaScript代码时,通过HTTP方式向本地程序发送地址访问请求,并通过地址访问请求中的本地操作标识指示本地程序执行相应的本地操作。 [0042] The embodiments of the present invention, the browser when the execution of the web application JavaScript code, sends an address access request, and instructs the local program executed corresponding local operation by the local operation identification address access request to the local application over HTTP. 因为,不同内核的浏览器通过http方式向本地程序发送地址访问请求,是没有区别的,所以,此方法可以提高网页程序触发本地操作的过程的通用性。 Because different kernel browser sent via http way to the local program address access request, there is no difference, therefore, this method can improve the local operating web applications trigger versatile process.

[0043] 实施例二 [0043] Second Embodiment

[0044] 本发明实施例提供了一种网页程序触发本地操作的方法。 Embodiment [0044] The present invention provides a method to trigger a local program page operation. 在该方法中,网页程序中设置有包含连接本地程序的HTTP链接的JavaScript代码。 In this method, the web is provided with the program code includes JavaScript program HTTP connection to the local link.

[0045] 其中,本地程序可以具体为本地服务器程序,本地设备运行该本地服务器程序,建立本地服务器。 [0045] wherein the specific local program may run the program for the local server the local server program, the local device establishing a local server. 本地程序可以预先安装到该本地设备中(如随系统配套安装),在系统启动时、或浏览器启动时、或打开相应的网页时启动该本地程序。 The local program start local program can be installed to the local device (e.g., with the system supporting the installation), at system startup, or when the browser starts, or open the respective pages. 除了上述的安装方式,还可以在浏览器执行网页程序时检测本地设备中是否已经安装该本地程序,如果没有安装,则通过浏览器弹出请求的方式,请求用户进行安装。 In addition to the installation, the local device may also detect whether the local program is already installed in the web browser execute a program, if not installed, the pop-up mode requested by the browser, requesting a user to install.

[0046]在本发明实施例中,网页程序中包含的连接本地程序的HTTP链接的JavaScript代码,是用于触发本地操作的JavaScript代码,该JavaScript代码中还包含有要触发的本地操作的本地操作标识。 [0046] In an embodiment of the present invention, the JavaScript code HTTP link connected to a local program included in the program Web page, the JavaScript code is used to trigger a local operation, the JavaScript code further includes a local operation of the local operation to be triggered identity. 一般的,网页程序中可以包含HTM L(Hyper Text Markup Language, 超文本标记语言)代码和JavaScript代码,HTM L代码可以用于静态的网页渲染,例如,图片显示、按钮位置设置和按钮图标的显示等,JavaScript代码可以用于动态功能的实现,例如,判断用户在网页中输入的字符是否符合要求。 In general, Web applications can be included in HTM L (Hyper Text Markup Language, HTML) code and JavaScript code, HTM L code can be used for static Web page rendering, for example, picture display, buttons, icons and buttons to set the position of the display etc., JavaScript code can be used to implement dynamic function, e.g., a character input by the user is determined to meet the requirements in the web page. 在网页程序中可以包含多段实现不同功能的JavaScript代码。 The page program can contain JavaScript code that implements different functions of multi-stage.

[0047]其中,本发明实施例提供的用于触发某个本地操作的JavaScript代码中,可以包含有连接本地程序的HTTP链接。 [0047] wherein, JavaScript code implementing the present invention provides for triggering a local operation, the program may contain an HTTP connection to the local link. 具体的,在该JavaScript代码中包含一个通过HTTP方式连接本地程序的语句,其中HTTP链接即为该本地程序的URL (Uniform/Universal Resource Locator,统一资源定位符),该URL中的域名可以为1 oca 1 ho st (本机域名),URL中的端口号可以是本地设备中系统分配给该本地程序的端口号。 Specifically, the connection comprises a local program statements by way of the HTTP JavaScript code, which is the URL of the HTTP link local program (Uniform / Universal Resource Locator, uniform resource locator), the URL may be a name oca 1 ho st (native domain name), the port number in the URL can be a local device in the system of the local port number assigned to the program. 如果本地设备注册有外网域名,URL中的域名也可以是此外网域名。 If the local device is registered outside of your domain name, URL of the domain name can also be a domain name addition.

[0048]下面将结合具体的实施方式,对图1所示的流程进行详细阐述,具体内容如下。 [0048] below with reference to specific embodiments, the flow of FIG. 1 explained in greater detail, as follows. [0049] 步骤101,本地程序接收浏览器在执行上述JavaScript代码的过程中根据该JavaScript代码中的该HTTP链接发送的地址访问请求。 [0049] Step 101, the local browser program receives the request during execution of the above-described JavaScript code to access the HTTP address link to the JavaScript code transmitted. 其中,该地址访问请求中携带有该JavaScript代码中记录的本地操作标识。 Wherein the address access request carries the identifier of the local operation of JavaScript code recorded.

[0050]具体的,浏览器可以在检测到相应的代码执行指令时,执行该JavaScript代码,该代码执行指令可以是操作指令(如用户点击网页按钮发出的指令),也可以是在加载网页程序的过程中网页程序直接发出的指令。 [0050] Specifically, the browser can upon detection of the corresponding code execution instruction, executes the JavaScript code that executed instructions may be instructions (such as a user click on the page button issue commands), may be loaded web applications the process of instruction web applications directly issued.

[0051]具体的,浏览器向本地程序发送地址访问请求的过程可以是:浏览器在执行JavaScript代码中相应的语句时,读取其中的URL,例如该URL可以是http: //localhost: 50001/(1;1:;^6;1:(:116〇1^。浏览器获取该1]1^的域名和端口号,然后生成地址访问请求,地址访问请求报文的报头中的目的地址可以由该域名对应的IP (Internet Protocol,互联网协议)地址和端口号组成,本机域名1 〇ca 1 h 〇st对应的IP地址为12 7.0.0.1,假设端口号为50001,那该地址访问请求的目的地址为127.0.0.1:50001。这样,该地址访问请求将通过本地设备中系统的该端口发送。又因为该JavaScript代码中的该HTTP链接的域名为本机域名,端口号为本地设备中系统分配给本地程序的端口号,所以,该地址访问请求将被发送给本地程序。 [0051] Specifically, the browser sends the address to the local access request procedure may be: when the browser execute JavaScript code corresponding statement, which read the URL, for example, the URL may be http: // localhost: 50001 / (1; 1:; ^ 6; 1]: ^ browser obtains the 116〇1 1] 1 ^ domain name and port number, and then generates the access request address, the destination address of the access request address packet header It may correspond by the domain IP (Internet protocol, Internet protocol) address and port number, the local domain 1 〇ca 1 h IP address corresponding to 〇st 12 7.0.0.1, assuming that port number is 50001, then the address access destination address request is 127.0.0.1:50001. Thus, the address access request sent through the port in the local system equipment and because of the HTTP link to the JavaScript code native domain name, port number of the local device the local port number assigned to the system program, so that the address access request is sent to the local program.

[0052] 一般的,浏览器在生成地址访问请求时,会在地址访问请求中携带请求访问的路径标识,该路径标识获取自HTTP链接,用于标识访问的内容的具体存储路径。 [0052] In general, when the browser generates an address access request, the access request carries the address of the access route request identifier, obtained from the HTTP link path identifier for identifying the contents of a specific memory access path. 在HTTP链接中,对于携带参数的情况,端口号后的7”和携带参数标识“?”之间的字符即为请求访问的路径标识,例如,某U RL为http: //localhost: 50001/drivercheck?token=iuxFx\px[a,该URL的路径标识则为d rivercheck;对于不携带参数的情况,端口号后的7”之后的字符则为请求访问的路径标识,例如,某URL为http: //localhost: 50001/dr ivercheck,该URL的路径标识则为drivercheck。 ? In the HTTP link in the case of carrying parameters, 7 "and carry identification parameters" after the port number of characters between "that is requesting access path identifier, for example, a U RL to http: // localhost: 50001 / ? drivercheck token = iuxFx \ px [a, the path of the URL identification was d rivercheck; the case where no carry parameters, compared to the characters after 7 "after the port number requesting access path identifier, e.g., a URL is http : // localhost: 50001 / dr ivercheck, the URL identifies the path was drivercheck. 对于HTTP链接中携带参数(通过“?token=”的形式)的情况,在地址访问请求中还会携带相应的参数。 For HTTP link carries parameters (by "? Token =" form) of the case, the address access request also carries the corresponding parameters.

[0053]浏览器可以通过该地址访问请求,携带相应的本地操作标识,以指导本地程序进行相应的本地操作,从而可以实现网页程序对本地操作的触发。 [0053] The browser can be accessed through the address request carrying identifier corresponding local operations to guide local program corresponding local operation, thereby triggering the local operation of the page program can be achieved.

[0054] 步骤102,本地程序根据接收到的本地操作标识,在本地设备中执行相应的本地操作。 [0054] Step 102, a local program according to the local operator identifier received, performs a corresponding local operating in the local device. 在本地程序中可以针对不同的本地操作标识,记录具体的执行方式,从而执行相应的本地操作。 Local procedures for different local operation can be identified, the recording specific implementation, such that the respective local operation.

[0055] 优选的,步骤101中的本地操作标识可以是HTTP链接中的路径标识,而且,在本地程序中可以记录路径标识与本地操作的对应关系,这时,步骤102的具体执行方式可以是: 本地程序根据记录的路径标识与本地操作的对应关系,确定地址访问请求中的路径标识对应的本地操作;本地程序在本地设备中执行该本地操作。 [0055] Preferably, the local operation identification step 101 may be a link in the path identifier HTTP, and may be recorded with the local path identifier corresponding relationship between the operation of the local program, then, in step 102 the specific implementation may be : native path identifier based on the correspondence and the operation of the local recording, the operation to determine the local path identification address corresponding to the access request; local program for executing the local operation in the local device.

[0056]具体的,本地程序中可以建立路径标识和本地操作的对应关系表,该路径标识可以只是一个逻辑标识,而并不存在相对应的实际路径,本地程序对于地址访问请求可以不进行常规的实际路径的访问处理,而是根据地址访问请求中的路径标识,在上述对应关系表中,查找到对应的本地操作,然后执行该本地操作。 [0056] Specifically, the local program can create a path identifier and the correspondence table of the local operation, identified by the path identifier may simply be a logical, but there is no actual path corresponding to the local address for the program may not be a conventional access request access processing actual path, but the path identifier according to the access request address in the correspondence table, find the corresponding local operation, and then performs the local operation.

[0057] 对于网页程序的提供方,在进行上述JavaScript代码的编辑之前,可以预先获取上述本地程序中记录的路径标识与本地操作的对应关系(即网页程序的提供方应该是预先已知该对应关系的),然后当编辑用于触发某本地操作的JavaScript代码时,可以根据该对应关系确定该本地操作对应的路径标识,作为JavaScript代码中的HTTP链接中的路径标识。 [0057] For a provider of web applications, prior to performing the edit JavaScript code described above, may be obtained in advance path identifier corresponding relationship between the operation of the local program recorded in the local (i.e., the page program providers should be known in advance the correspondence relationship), then when editing JavaScript code to trigger a local operation, it may be determined according to the correspondence of the path identifier corresponding to the local operation, as an HTTP link JavaScript code in the path identifier.

[0058] 另外,出于安全性的考虑,可以要求在用于触发本地操作的JavaScri pt代码中记录预先约定好的密钥,以防止非法网页程序进行本地操作。 [0058] Further, for security reasons, the recording may require pre-agreed key, to prevent illegal operation of the page program JavaScri pt local code to trigger a local operation. 浏览器在发送地址访问请求时, 可以在地址访问请求中携带JavaScript代码中记录的密钥。 When the browser sends an address request access, the key can carry JavaScript code recorded in the address access request. 这样,本地程序可以将地址访问请求中携带的密钥与本地程序中存储的密钥进行对比,如果匹配,则根据本地操作标识, 在本地设备中执行相应的本地操作。 Thus, the address can be a local program key and the access key stored in the local program carried in the request are compared, and if they match then the operation in accordance with the local identifier, the local operation performed in the respective local device. 如果不匹配,则可以拒绝在本地设备中执行相应的本地操作。 If not, it may refuse to carry the corresponding local operating in the local device. 优选的,在JavaScript代码中,密钥可以在HTTP链接中以参数的形式记录,这样,浏览器在发送地址访问请求时,就会将密钥以参数的形式携带于地址访问请求中。 Preferably, in the JavaScript code, it may be recorded in the form of key parameters in the HTTP links, so that, when the browser sends an address access request, the key will be carried in the access request address as a parameter.

[0059] 在执行完上述步骤102之后,如果执行的本地操作需要向浏览器返回执行结果,那还可以包括如下的步骤:本地程序向浏览器发送JavaScript代码形式的答复消息,该答复消息中携带有上述执行的本地操作的执行结果。 [0059] After performing step 102, if the local operation performed need to return an execution result to the browser, it may further comprise the steps of: a local program to send JavaScript code in the form of a reply message to the browser, the reply message carries It has an execution result of the execution of local operations. 例如,该执行结果可以是本地操作执行成功,也可以是本地操作执行失败,还可以是本地操作获取的数据等。 For example, the execution result may be a local operation executed successfully, or may be a local operation fails, the operation may also be locally acquired data.

[0060] 基于HTTP协议,JavaScript代码是不允许进行跨域数据获取的,即JavaScript代码只能在提供其所属的网页程序的网站的域名下获取数据,而不能在其它域名下获取数据。 [0060] based on the HTTP protocol, JavaScript code does not allow cross-domain data acquisition, that JavaScript code can only get the data provided in the domain name of the site to which it belongs web applications, and can not get the data in other domains. 而在本发明实施例中,本地程序和提供网页程序的网站具有不同的域名,浏览器如果要接收本地程序发送的数据,实际是属于跨域数据获取行为,是会被浏览器拒绝的。 In embodiments of the invention, the Web site that provides local program, and the program has a different domain name, browser to receive local program if the transmitted data, the actual behavior belongs cross-domain data acquisition, it will be rejected browser. 所以,本发明实施例提供了上述发送执行结果的方式,将数据的发送转换为某段JavaScript代码的发送,这样数据的获取过程就转换成为某段JavaScript代码的加载过程。 Therefore, the present invention provides a way to send the results of the above, and transmits the converted data to transmit certain JavaScript code, the process of obtaining this data will be converted into a certain loading JavaScript code. 在HTTP协议中,跨域的JavaScript代码加载是允许进行的,所以通过上述方法可以实现本地操作执行结果的反馈。 In the HTTP protocol, cross-domain JavaScript code is allowed to load and local feedback operation can be realized by the above process execution result.

[0061] 此携带执行结果的JavaScript代码的具体内容参数可以根据具体情况预先设置, 并在本地程序中与本地操作对应的记录。 [0061] This specific content parameter carrying JavaScript code execution results may be provided in advance depending on the circumstances, and the operation corresponding to the local record in the local program.

[0062]另外,浏览器在接收到本地程序反馈的JavaScript代码形式的答复消息之后,可以获取答复消息中携带的所述本地操作的执行结果,然后对所述执行结果进行显示。 [0062] Further, after the browser receives the native form of JavaScript code reply message feedback can be acquired execution result of the local operation carried reply message, and then the execution result is displayed.

[0063] 本发明实施例中,浏览器在执行网页程序的JavaScript代码时,通过HTTP方式向本地程序发送地址访问请求,并通过地址访问请求中的本地操作标识指示本地程序执行相应的本地操作。 [0063] The embodiments of the present invention, the browser when the execution of the web application JavaScript code, sends an address access request, and instructs the local program executed corresponding local operation by the local operation identification address access request to the local application over HTTP. 因为,不同内核的浏览器通过HTTP方式向本地程序发送地址访问请求,是没有区别的,所以,此方法可以提高网页程序触发本地操作的过程的通用性。 Because different kernel browser to send HTTP to local programs to address access request, there is no difference, therefore, this method can increase the versatility of web applications trigger local operation of the process.

[00M] 实施例三 [00M] Example three

[0065]基于相同的技术构思,本发明实施例提供了一种网页程序触发本地操作的装置, 该装置的功能可以通过本地程序来实现。 [0065] Based on the same technical concept, embodiments provide an apparatus for the page program operation of the present invention to trigger a local function of the apparatus may be implemented by a local program. 网页程序中设置有包含连接本地程序的HTTP链接的JavaScript代码,如图2所不,所述装置包括: Web applications JavaScript code is provided comprising an HTTP connection to the local program link, not shown in FIG 2, the apparatus comprising:

[0066] 接收模块210,用于接收浏览器在执行所述JavaScript代码的过程中根据所述JavaScript代码中的所述HTTP链接发送的地址访问请求,所述地址访问请求中携带有所述JavaScript代码中记录的本地操作标识; Process [0066] The receiving module 210 for receiving the browser execute JavaScript code in the address of the access request from the HTTP link JavaScript code transmitted, the access request carries the address of the JavaScript code local operation record identifier;

[0067] 执行模块220,用于根据所述本地操作标识,在所述本地设备中执行相应的本地操作。 [0067] The execution module 220 for operation in accordance with the local identifier, the corresponding local operation performed in the local apparatus.

[0068] 优选的,所述本地操作标识具体为所述HTTP链接中的路径标识; [0068] Preferably, the identifier identifies a specific operation to local HTTP link in the path;

[0069] 所述执行模块220中记录有路径标识与本地操作的对应关系; [0069] The execution module 220 corresponding relationship path identifier is recorded with the local operation;

[0070] 所述执行模块220,具体用于:根据记录的路径标识与本地操作的对应关系,确定所述地址访问请求中的路径标识对应的本地操作;在所述本地设备中执行该本地操作。 [0070] The executing module 220, configured to: according to a correspondence relationship between the path identifier and the local operation record, to determine local operating path identifier corresponding to said address access request; the local operation performed in the local apparatus .

[0071] 优选的,所述执行模块220,还用于: [0071] Preferably, the execution module 220 is further configured to:

[0072] 向所述浏览器发送JavaScript代码形式的答复消息,所述答复消息中携带有所述本地操作的执行结果。 [0072] JavaScript code sent to the browser in the form of a reply message, the reply message carries an execution result of the local operation.

[0073] 优选的,所述HTTP链接中的域名具体为本机域名,所述HTTP链接中的端口号具体为本地设备中系统分配给所述本地程序的端口号。 [0073] Preferably, the HTTP link specific native domain name, port number of the port number in the HTTP link to the local device specifically allocated to the local system program.

[0074] 优选的,所述地址访问请求中还携带有所述JavaScript代码中记录的密钥; [0074] Preferably, the address access request further carries the JavaScript code recorded in the key;

[0075] 所述执行模块220,具体用于:将所述地址访问请求中携带的密钥与所述本地程序中存储的密钥进行对比,如果匹配,则根据所述本地操作标识,在所述本地设备中执行相应的本地操作。 [0075] The executing module 220, configured to: the program key with the local address of the access request key stored in the comparison, if a match is identified according to the local operation, in the said local device performs the corresponding local operation.

[0076] 本发明实施例中,浏览器在执行网页程序的JavaScript代码时,通过HTTP方式向本地程序发送地址访问请求,并通过地址访问请求中的本地操作标识指示本地程序执行相应的本地操作。 [0076] The embodiments of the present invention, the browser when the execution of the web application JavaScript code, sends an address access request, and instructs the local program executed corresponding local operation by the local operation identification address access request to the local application over HTTP. 因为,不同内核的浏览器通过HTTP方式向本地程序发送地址访问请求,是没有区别的,所以,此方法可以提高网页程序触发本地操作的过程的通用性。 Because different kernel browser to send HTTP to local programs to address access request, there is no difference, therefore, this method can increase the versatility of web applications trigger local operation of the process.

[0077] 需要说明的是:上述实施例提供的网页程序触发本地操作的装置在触发本地操作时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。 [0077] Note that: the above-described embodiments means the page program provided by local operation of the trigger when the trigger local operation, division of the foregoing functional modules illustrated practical application, the above functions may be required performed by different functional modules, the internal structure of the apparatus is divided into different functional modules to complete all or part of the functions described above. 另外,上述实施例提供的网页程序触发本地操作的装置与网页程序触发本地操作的方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。 The method further apparatus, Web applications provided by the above embodiments and trigger the local operation of the page program operation of the embodiment trigger a local belong to the same concept, embodiments of the method specific implementation process thereof will not be repeated here.

[0078] 上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。 Embodiment [0078] The present invention No. merely for description, the embodiments do not represent the merits embodiment.

[0079] 本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。 [0079] Those of ordinary skill in the art may understand that the above embodiments all or part of the steps may be implemented by hardware, by a program instruction may be relevant hardware, the program may be stored in a computer-readable storage medium in the above-mentioned storage medium may be a read-only memory, magnetic or optical disk.

[0080]以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。 [0080] The foregoing is only preferred embodiments of the present invention, not intended to limit the present invention within the spirit and principle of the present invention, any modification, equivalent replacement, or improvement, it should be included in the present within the scope of the invention.

Claims (7)

  1. 1. 一种网页程序触发本地操作的方法,其特征在于,网页程序中设置有包含连接本地程序的HTTP链接的JavaScript代码,所述方法包括: 所述本地程序接收浏览器在执行所述JavaScript代码的过程中根据所述JavaScript 代码中的所述HTTP链接发送的地址访问请求,所述地址访问请求中携带有所述JavaScript 代码中记录的本地操作标识; 所述本地程序根据所述本地操作标识,在本地设备中执行相应的本地操作; 所述HTTP链接中的域名具体为本机域名,所述HTTP链接中的端口号具体为本地设备中系统分配给所述本地程序的端口号; 所述本地操作标识具体为所述HTTP链接中的路径标识; 所述本地程序中记录有路径标识与本地操作的对应关系; 所述本地程序根据所述本地操作标识,在所述本地设备中执行相应的本地操作,具体为:所述本地程序根据记录的路径标识与本地操 1. A method of triggering a local page program operation, wherein the web is provided with a JavaScript program code includes program HTTP connection to the local link, the method comprising: receiving the local browser program executing the JavaScript code during the address of the HTTP link JavaScript code transmitted access request according to the access request carries an address of the local operation JavaScript recorded identification code; said local identification procedure according to the local operation, local operation performed in the respective local device; HTTP link in the specific native domain name, port number of the HTTP link to the specific program is assigned to the local device, the local port number system; the local DETAILED operation identifier identifies the HTTP link in the path; the local program is recorded in a corresponding relationship with the local operation path identifier; said local identification procedure according to the local operation, performed in the corresponding local local device operation, in particular: a program according to the local path of the recording operation of identifying local 的对应关系,确定所述地址访问请求中的路径标识对应的本地操作;所述本地程序在所述本地设备中执行该本地操作。 Correspondence between the operation path to determine the local address of the access request corresponding to the identifier; the local program executing on the local operation of the local device.
  2. 2. 根据权利要求1所述的方法,其特征在于,所述方法还包括: 所述本地程序向所述浏览器发送JavaScript代码形式的答复消息,所述答复消息中携带有所述本地操作的执行结果。 2. The method according to claim 1, characterized in that, said method further comprising: sending the local program to the browser in the form of JavaScript code reply message, the reply message carries the local operation Results of the.
  3. 3. 根据权利要求2所述的方法,其特征在于,所述本地程序向所述浏览器发送JavaScript代码形式的答复消息之后,还包括: 所述浏览器获取所述答复消息中携带的所述本地操作的执行结果; 所述浏览器对所述执行结果进行显示。 3. After the method according to claim 2, wherein said local transmitting program JavaScript code in the form of a reply message to the browser, further comprising: the browser to retrieve the reply message carried in the local operation execution result; the browser displays the execution result.
  4. 4. 根据权利要求1所述的方法,其特征在于,所述地址访问请求中还携带有所述JavaScript代码中记录的密钥; 所述本地程序根据所述本地操作标识,在所述本地设备中执行相应的本地操作,具体为:所述本地程序将所述地址访问请求中携带的密钥与所述本地程序中存储的密钥进行对比,如果匹配,则根据所述本地操作标识,在所述本地设备中执行相应的本地操作。 4. The method according to claim 1, wherein said address access request further carries the JavaScript code recorded in the key; said local operation procedure according to the local identifier, the local device corresponding local operation performed, specifically: the local program key with the local address of the program access request stored in the key comparison, if a match is identified according to the local operation, in performing the local operation of the respective local apparatus.
  5. 5. —种网页程序触发本地操作的装置,其特征在于,网页程序中设置有包含连接本地程序的HTTP链接的JavaScript代码,所述装置包括: 接收模块,用于接收浏览器在执行所述JavaScript代码的过程中根据所述JavaScript 代码中的所述HTTP链接发送的地址访问请求,所述地址访问请求中携带有所述JavaScript 代码中记录的本地操作标识; 执行模块,用于根据所述本地操作标识,在本地设备中执行相应的本地操作; 所述HTTP链接中的域名具体为本机域名,所述HTTP链接中的端口号具体为本地设备中系统分配给所述本地程序的端口号; 所述本地操作标识具体为所述HTTP链接中的路径标识; 所述执行模块中记录有路径标识与本地操作的对应关系; 所述执行模块,具体用于:根据记录的路径标识与本地操作的对应关系,确定所述地址访问请求中的路径标识对应的本地操作;在 5. - Species page program triggers local operation means, characterized in that the web is provided with a JavaScript program code includes program HTTP connection to the local link, the apparatus comprising: a receiving module, for receiving the browser executing the JavaScript procedure code of the address to access the HTTP link JavaScript code transmission request, the access request carries an address of the local operation JavaScript identification code recorded; execution module, according to the local operation identification, performed in the local apparatus in respective local operation; HTTP link in the specific native domain name, port number of the HTTP link to the specific program is assigned to the local device, the local port number system; the said local operation identifier identifies the specific path HTTP links; module corresponding relationship with the local path identifier recorded in the execution operation; the execution module is configured to: identify a corresponding operation according to the local path of the recording relationship determining operating path of the local address of the access request corresponding to the identifier; in 所述本地设备中执行该本地操作。 The local operation performing the local device.
  6. 6. 根据权利要求5所述的装置,其特征在于,所述执行模块,还用于: 向所述浏览器发送JavaScript代码形式的答复消息,所述答复消息中携带有所述本地操作的执行结果。 6. The apparatus as claimed in claim 5, wherein said performing module is further configured to: send a reply message in the form of JavaScript code to the browser, the reply message carries the local operation is performed result.
  7. 7.根据权利要求5所述的装置,其特征在于,所述地址访问请求中还携带有所述JavaScript代码中记录的密钥; 所述执行模块,具体用于:将所述地址访问请求中携带的密钥与所述本地程序中存储的密钥进行对比,如果匹配,则根据所述本地操作标识,在所述本地设备中执行相应的本地操作。 7. The apparatus as claimed in claim 5, wherein said address access request further carries the JavaScript code recorded in the key; said execution module is configured to: request access to the address carried by the local program key and stored key comparison, if a match is identified according to the local operation, performed at the local operation of the respective local device.
CN 201210568093 2012-12-24 2012-12-24 A method and apparatus for triggering the local program page operation CN103902534B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201210568093 CN103902534B (en) 2012-12-24 2012-12-24 A method and apparatus for triggering the local program page operation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201210568093 CN103902534B (en) 2012-12-24 2012-12-24 A method and apparatus for triggering the local program page operation

Publications (2)

Publication Number Publication Date
CN103902534A true CN103902534A (en) 2014-07-02
CN103902534B true CN103902534B (en) 2018-04-27

Family

ID=50993864

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201210568093 CN103902534B (en) 2012-12-24 2012-12-24 A method and apparatus for triggering the local program page operation

Country Status (1)

Country Link
CN (1) CN103902534B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105159875A (en) * 2015-09-11 2015-12-16 北京恒华伟业科技股份有限公司 File editing method and device
CN105577764B (en) * 2015-12-16 2017-06-23 北京浩瀚深度信息技术股份有限公司 A user clicks identification method, server and system
CN105959278A (en) * 2016-04-28 2016-09-21 北京网康科技有限公司 Method, device and system for calling VPN

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101488143A (en) * 2008-01-16 2009-07-22 重庆安软信息科技有限公司 Novel web application and local application interaction mode
CN101681343A (en) * 2007-06-13 2010-03-24 微软公司 Systems and methods for providing desktop or application remoting to a web browser

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7555529B2 (en) * 1995-11-13 2009-06-30 Citrix Systems, Inc. Interacting with software applications displayed in a web page
US20040260806A1 (en) * 2003-06-20 2004-12-23 Eric Martin System supporting communication between a web enabled application and another application
US8862696B2 (en) * 2009-09-08 2014-10-14 Sony Corporation Interconnecting applications on personal computers and mobile terminals through a web server
CN102393857B (en) * 2011-11-01 2014-04-09 中兴通讯股份有限公司 Method and system for local call based on web page

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101681343A (en) * 2007-06-13 2010-03-24 微软公司 Systems and methods for providing desktop or application remoting to a web browser
CN101488143A (en) * 2008-01-16 2009-07-22 重庆安软信息科技有限公司 Novel web application and local application interaction mode

Also Published As

Publication number Publication date Type
CN103902534A (en) 2014-07-02 application

Similar Documents

Publication Publication Date Title
Wang et al. The Multi-Principal OS Construction of the Gazelle Web Browser.
US20060294196A1 (en) Method and system for storing a web browser application session cookie from another client application program
US20120210243A1 (en) Web co-navigation
De Keukelaere et al. Smash: secure component model for cross-domain mashups on unmodified browsers
US20050021791A1 (en) Communication gateway apparatus, communication gateway method, and program product
US20090276835A1 (en) Secure cross-domain communication for web mashups
US20110154130A1 (en) Method and apparatus for secure cross-site scripting
US20050091341A1 (en) Detecting a reverse proxy and establishing a tunneled connection therethrough
US20170272316A1 (en) Managing network connected devices
US20110138074A1 (en) Content distribution management device, terminal, program, and content distribution system
US20070299938A1 (en) Method and system for enhancing a home page
CN104796396A (en) Network proxy layer for policy-based application proxies
CN101964025A (en) XSS (Cross Site Scripting) detection method and device
CN101178717A (en) Method for adaptation processing web page and web page adaptation device
CN102932197A (en) Testing method and system
US8464318B1 (en) System and method for protecting web clients and web-based applications
Bohannon et al. Featherweight Firefox: formalizing the core of a web browser
US20130212689A1 (en) Managing network data
US20040103078A1 (en) Web server hit multiplier and redirector
US20100049782A1 (en) Method and apparatus for cross-domain communication
CN102419808A (en) Method, device and system for detecting safety of download link
US20070283421A1 (en) Recording medium storing control program and communication system
CN101431713A (en) Resource access method and equipment
CN103034727A (en) System for intercepting pop-up window in webpage
CN101697139A (en) Method, device and registry for remote procedure call

Legal Events

Date Code Title Description
C06 Publication
C10 Entry into substantive examination
GR01