js遠程程序,程序員遠程

本文目錄一覽:

JAVASCRIPT如何獲取遠程頁面內容

JS AJAX技術獲取網頁源代碼是不行的…

要用其他方法…

例如,我用PHP的套接字模擬HTTP協議的方式編寫一個獲取源代碼的PHP程序.

再用JS AJAX調用這個PHP程序.. 就能實現跨域了..

當然,你如果會JAVA,直接寫個JAVA Applet也行…利用 URLConnection類,獲取源代碼輕而易舉…

如何實現 JS 遠程控制服務器開關機?

首先,你的服務器JS是控制不了的,必須用C,C++之類的後台語言控制,至於JS就是發個信號給你的服務器,讓你的服務器後台語言控制這個服務器的開和關

js 遠程調用 怎麼實現

RMI:  Remote Method Invoke 遠程方法調用

用js調用java,java實現遠程調用。

jsonRPC 機制調用

ajax 調用

JavaScript怎麼連接遠程服務器,只要能建立通信就行。不需要任何功能?

你說的連接是指什麼?訪問也是連接啊,你用js從遠程服務器下載一個文件,這也算連接啊。

如果你是指登錄遠程服務器的話,這個需要遠程服務器首先提供了登錄接口,否則是登錄不了的

遠程調用js

JsLoader,動態加載遠程js代碼

/**

* Construct a new JSLoaderEnvironment instance

* @class JSLoaderEnvironment is the class designed to be a

* representation of a unix-like shell environment.

* The purpose of this is to allow the infrastructure to abstract

* away any library file location knowledge for rapid and enterprise

* adoption and deployment

*/

function JSLoaderEnvironment(){

// Default

this.prefix=”/assets/”;

// Auto-discover location

var _remote=false;

var s=0;

var _script_tags=document.getElementsByTagName(“script”);

var endsWith=function(str, substr){

return (str str.indexOf(substr) == (str.length-substr.length));

};

for(s=0;s_script_tags.length;++s){

var src=_script_tags[s].src;

var src_orig=src;

if(src){

if(src.indexOf(“://”)-1)

{

src=src.substring(src.indexOf(“://”)+3);

src=src.substring(src.indexOf(“/”));

}

if(endsWith(src,”jsloader.js”) || endsWith(src,”jsloader-debug.js”)) {

// If the domain is remote, assume we’re running in hosted mode

_remote=(src_orig.indexOf(document.domain)==-1);

if(_remote) src=src_orig;

this.prefix=src.substring(0, src.lastIndexOf(“/”)+1);

}

}

}

/**

* @private

*/

this.suffix=”.js”;

/**

* @private

* Make the Path of a module to meta/proj/release

*/

this.makeJSLoaderPath=function(m,p,r,suff){

// if just a url is specified, use it

if(!p !r) return this.stripExternalRef(m);

// build the m/p/r path

return this.prefix+m+”/”+p+”/incr/versions/”+r+ ((suff)?this.suffix:””);

}

/**

* The generate the path prefix for a MPR linked into the JSLoader Environmentiables

* @param m meta

* @param p project

* @param r release

*/

this.makePath=function(m,p,r){

// if just a url is specified, use it

if(!p !r) return this.stripExternalRef(m);

// build the m/p/r path

return this.prefix + m +”/” + p + “/” + r + “/”;

}

/**

* @private

*/

this.env=new Object();

/**

* @private

*/

this.loaders=new Object();

/**

* The sets an environment variable (make sure it’s safe for JS Object[key] notation)

* The idea here is that modules could set this, and pages which load the module

* can then get the Environment variables

* @param k javascript object[key]

* @param v value (technically could be of any type…)

*/

this.setEnv=function(k,v){

this.env[k]=v;

}

/**

* The gets an environment variable previously set

* @param k javascript object[key]

* @returns the value set for this key

*/

this.getEnv=function(k){ return this.env[k];}

/**

* Lists all modules

* loaded in this environment.

* @private

*/

this._loadedJSLoaders=new Object();

/**

* This makes a normalized key to stick into loaded_modules and verify if things are loaded.

* @private

*/

this.normalize=function(m,p,r){ return (m+”__”+p+”__”+r).toLowerCase();};

/**

* This checks whether the given meta/project/release is already loaded.

* @param m metaproject (or the path of a JS file, if no other args are passed)

* @param p project

* @param r release

* @type boolean

* @returns Whether m/p/r is loaded

*/

this.isLoaded=function(m,p,r){

var xkey=this.normalize(m,p,r);

return(this._loadedJSLoaders[xkey]!=null);

};

/**

* Gets a “loader” based on the MPR specified in the arguments

* This is useful for loading subpackages. You can call {@link JSSubLoader#load} or {@link JSSubLoader#loadAll} on this

* and it will load submodules under a folder with the “release” number

* @see JSSubLoader

* @param m metaproject

* @param p project

* @param r release

* @returns void

*/

this.getLoader=function(m,p,r){

var key=this.normalize(m,p,r);

var loader=this.loaders[key];

if(loader) {

return loader;

}

else {

loader=new JSSubLoader(this,this.makeJSLoaderPath(m,p,r,false)+”/”);

var __path=this.makePath(m,p,r);

this.setEnv(p.toUpperCase()+”_PATH”,__path);

this.loaders[key]=loader;

return loader;

}

}

/**

* Loads the requested module into the environment

* You can also load your own module by calling loadJavascript(url) if you want

* @param m metaproject

* @param p project

* @param r release

* @type boolean

* @returns void

*/

this.load=function(m,p,r){

var key=this.normalize(m,p,r);

var url=this.makeJSLoaderPath(m,p,r,true);

try{

if(this.isLoaded(m,p,r)) {

return;

}

this.loadJavaScript(url);

this._loadedJSLoaders[key]=”true”;

} catch (e){ this.handleError(e); }

};

/**

* Loads a JavaScript file into the page

* @param {String} url the url of the javascript file

*/

this.loadJavaScript=function (url){

url = this.stripExternalRef(url);

document.writeln(“scri”+”pt src='”+url+”‘ type=’text/javascript’/sc”+”ript”);

};

/**

* Loads a JavaScript file into the page

* @param {String} url the url of the javascript file

*/

this.loadStyleSheet=function(url){

url = this.stripExternalRef(url);

document.writeln(“li”+”nk rel=’stylesheet’ href='”+url+”‘ type=’text/css’/li”+”nk”);

};

/**

* Strips out any double slashes, double dots, or cross domain references.

* @param s string

*/

this.stripExternalRef=function(s){

var exprs = [/\.\.+/g,/\/\/+/g,/\\\\+/g,/\:+/g,/\’+/g,/\%+/g];

// If it’s hosted, we relax the protocol related regex

exprs = [/\.\.+/g,/\\\\+/g,/\’+/g,/\%+/g];

if (_remote)

for(var i=0; iexprs.length; i++)

{

s = s.replace(exprs[i], ”);

}

return s;

}

/**

* Overwritable error handler

*/

this.handleError=function(e) {

}

return this;

};

/**

* Construct a new JSSubLoader instance. You shoudl never need to call this, as {@link JSLoaderEnvironment#getLoader} gets you one of these from the environment.

* @class JSSubLoader is designed to load “sub” modules

* This is a wrapper which is produced when you call {@link JSLoaderEnvironment#getLoader}

* It is designed to allow sub-packages within a given MPR to be loaded easily. This is constructed by JSLoader.getLoader() call

* so you should never really need to construct one of these.

* @constructor

* @param {JSLoaderEnvironment} env_

* @param {String} prefix_ The path underneath which the submodules reside

*

*/

function JSSubLoader(env_, prefix_){

/**

* @private

*/

this.environment=env_;

/**

* @private

*/

this.prefix=prefix_;

/**

* @private

*/

this.loaded=new Object();

/**

* @private

*/

this.normalize=function(str){ return str.toLowerCase(); }

/**

* Loads an array of subpackages

* @param {Array} pkgs an array of packages.

*/

this.loadAll=function(pkgs_){

for(i=0;ipkgs_.length;++i) this.load(pkgs_[i]);

};

/**

* Loads a subpackage, if it’s not already loaded

* @param {String} url the url of the sub-package module file (m/p/r/submodule.js)

*/

this.load=function(pkg){

var p=this.normalize(pkg);

if (this.loaded[p]) {

return;

}

this.loaded[p]=pkg;

this.environment.loadJavaScript(prefix_+pkg+”.js”);

};

};

JSLoader = new JSLoaderEnvironment();

// LocalWords: fileoverview

原創文章,作者:BIRD,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/147230.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
BIRD的頭像BIRD
上一篇 2024-11-01 14:07
下一篇 2024-11-01 14:07

相關推薦

  • JS Proxy(array)用法介紹

    JS Proxy(array)可以說是ES6中非常重要的一個特性,它可以代理一個數組,監聽數據變化並進行攔截、處理。在實際開發中,使用Proxy(array)可以方便地實現數據的監…

    編程 2025-04-29
  • python強行終止程序快捷鍵

    本文將從多個方面對python強行終止程序快捷鍵進行詳細闡述,並提供相應代碼示例。 一、Ctrl+C快捷鍵 Ctrl+C快捷鍵是在終端中經常用來強行終止運行的程序。當你在終端中運行…

    編程 2025-04-29
  • Python程序需要編譯才能執行

    Python 被廣泛應用於數據分析、人工智能、科學計算等領域,它的靈活性和簡單易學的性質使得越來越多的人喜歡使用 Python 進行編程。然而,在 Python 中程序執行的方式不…

    編程 2025-04-29
  • 兼職程序員能掙錢嗎?

    可以。不過,兼職程序員賺錢的關鍵就在於如何找到並利用合適的機會。 一、掌握技能 作為程序員,掌握必要的技能是兼職掙錢的前提。除了紮實的編程技能,了解相關工具和平台也非常重要。常見的…

    編程 2025-04-29
  • Python程序文件的拓展

    Python是一門功能豐富、易於學習、可讀性高的編程語言。Python程序文件通常以.py為文件拓展名,被廣泛應用於各種領域,包括Web開發、機器學習、科學計算等。為了更好地發揮P…

    編程 2025-04-29
  • Python購物車程序

    Python購物車程序是一款基於Python編程語言開發的程序,可以實現購物車的相關功能,包括商品的添加、購買、刪除、統計等。 一、添加商品 添加商品是購物車程序的基礎功能之一,用…

    編程 2025-04-29
  • 爬蟲是一種程序

    爬蟲是一種程序,用於自動獲取互聯網上的信息。本文將從如下多個方面對爬蟲的意義、運行方式、應用場景和技術要點等進行詳細的闡述。 一、爬蟲的意義 1、獲取信息:爬蟲可以自動獲取互聯網上…

    編程 2025-04-29
  • Vb運行程序的三種方法

    VB是一種非常實用的編程工具,它可以被用於開發各種不同的應用程序,從簡單的計算器到更複雜的商業軟件。在VB中,有許多不同的方法可以運行程序,包括編譯器、發佈程序以及命令行。在本文中…

    編程 2025-04-29
  • Python一元二次方程求解程序

    本文將詳細闡述Python一元二次方程求解程序的相關知識,為讀者提供全面的程序設計思路和操作方法。 一、方程求解 首先,我們需要了解一元二次方程的求解方法。一元二次方程可以寫作: …

    編程 2025-04-29
  • 如何使用GPU加速運行Python程序——以CSDN為中心

    GPU的強大性能是眾所周知的。而隨着深度學習和機器學習的發展,越來越多的Python開發者將GPU應用於深度學習模型的訓練過程中,提高了模型訓練效率。在本文中,我們將介紹如何使用G…

    編程 2025-04-29

發表回復

登錄後才能評論