Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

A case study of ie Jump chrome

Shulou Source: shulou.com Published: 2022-06-01 23:06:58 09月30日 Update

This article introduces the relevant knowledge of "ie Jump chrome case Analysis". In the operation of the actual case, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. introduction

The customer has two systems, system one is compatible with IE, system two is compatible with Google, and needs to achieve single sign-on of the system, from system one to system two, that is, to jump from IE to Google to open system two.

Implementation: the client opens a nodejs service, forwards the request, and uses the child_process component of nodejs to launch Google browser to access the target link.

II. Preparatory work

Install nodejs, select the installation package according to the version of the operating system, and the installation process will not be repeated.

Http://nodejs.cn/download/

Installation complete, test:

3. Create a new file ie2chrome.js (must be in the English path), and the file content is encoded in utf-8 format.

Var http = require ('http'); var open = require (' open'); var url = require ('url'); var cp = require (' child_process'); http.createServer (function (request, response) {/ / Encoding setting response.writeHead (200,{ 'Content-Type':' text/plain;charset=utf-8'}); / / get the parameter var requset_url = request.url in get request / / convert string format parameters to objects using var param = url.parse (requset_url,true). Query / / jump page var redirect_uri = 'start chrome http://www.baidu.com?userId='+param.userId; / / Google browser to open and decompile / / open (decodeURIComponent (redirect_uri), "chrome") / / cp.exec ('start chrome http://www.baidu.com') cp.exec (redirect_uri); / / send response data "Hello World" response.end (' have a nice day at work ~ you have jumped to another page to open the system. \ n');}) .printer (8888); / / the terminal prints the following information console.log ('Server running at http://127.0.0.1:8888/');)

Fourth, install child_process components

To execute npm install child_process, the default installation path is generally (C:\ Users\ w\ node_modules) according to whether the user name is not the same.

Copy it from the installed file and put it at the same level as ie2chrome.js

5. Testing

Open a command window to execute:

If you report an error, you can set the environment variable: NODE_PATH=E:\ workspace\ ie2chrome\ node_modules

Visit: http://localhost:8888/?userId=aaaa

6. Set the system to start automatically. I have tried to register as a system service, but I can't start Google. I can't find the reason. Here, set the system startup item and start the service automatically.

Create a new run.vbs

Set ws = CreateObject ("Wscript.Shell") ws.run "cmd / c node ie2chrome.js", vbhide

Create a new run.bat

@ echo offset NODE_PATH=%~dp0\ node_modules:: executes start "% ~ dp0\" run.vbs ":: close the cmd command window taskkill / f / im cmd.exeexit after executing the command

Test: double click to run run.bat in a flash

Open the Task Manager

Visit: http://localhost:8888/?userId=aaaa

Run.bat right-click to create a shortcut, cut and put the created shortcut into the directory (different computer paths may be different):

C:\ Users\ w\ AppData\ Roaming\ Microsoft\ Windows\ Start Menu\ Programs\ Startup.

Start-"run input: msconfig to view startup items:

Restart the computer, visit: http://localhost:8888/?userId=aaaa

If you report an error, try the following solution, recreate the shortcut and copy to the startup item

This is the end of the "ie Jump chrome case study". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Systems paths cases content commands files methods services tests case studies analysis differences parameters customers solutions more results formats browsers computers Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Redmi vpn Apple Shulou Tech Info