Execute javascript on IIS server

2020-04-04 16:58发布

I have the following situation. A customer uses JavaScript with jQuery to create a complex website. We would like to use JavaScript and jQuery on the server (IIS) for the following reasons:

  1. Skills transfer - we would like to use JavaScript and jQuery on the server and not have to use eg VB Script. / classic asp. .Net framework/Java etc is ruled out because of this.

  2. Improved options for search/accessibility. We would like to be able to use jQuery as a templating system, but this isn't viable for search engines and users with js turned off - unless we can selectively run this code on the server.

There is significant investment in IIS and Windows Server, so changing that is not an option.

I know you can run jScript on IIS using windows Script host, but am unsure of the scalability and the process surrounding this. I am also unsure whether this would have access to the DOM.

Here is a diagram that hopefully explains the situation. I was wondering if anyone has done anything similar?

EDIT: I am not looking for critic on web architecture, I am simply wanting to know if there are any options for manipulating the DOM of a page before it is sent to the client, using javascript. Jaxer is one such product (no IIS) Thanks.

7条回答
Emotional °昔
2楼-- · 2020-04-04 17:23

Have a look at bringing the browser to the server, Rhino, and Use Microsoft's IIS as a Java servlet engine.

The first link is from John Resig's (jQuery's creator) blog.

Update August 2 2011

Node.js is coming to Windows.

查看更多
唯我独甜
3楼-- · 2020-04-04 17:24

JScript runs on IIS via something called ASP.
Active Server Pages.
It was first available in 1996.

Eventually ASP.NET was introduced as a successor. But ASP is still supported.

There is no DOM for the HTML page, though.

You might need to reconsider your architecture a bit.

查看更多
萌系小妹纸
4楼-- · 2020-04-04 17:35

I think it's mainly a browser based script so probably you are better of using technologies based on VB or .NET to perform or generate HTML from templates. I'm sure there are because in the java world there are a few of these around (like velocity). You'd then use jQuery to create or add client side functionality and usability so it makes the website more usable than it would have been.

查看更多
Explosion°爆炸
5楼-- · 2020-04-04 17:36

The idea to reuse client JS on the server may sound tempting, but I am not sure that jQuery itself would be ready to run in server environment.

You will need to define global context for jQuery somehow by initializing window, document, self, location, etc.. I am not sure it is doable.

Besides, as Cheeso has mentioned, Active Server Pages is a very outdated technology, it was replaced with ASP.Net by Microsoft in the beginning of the century. I used to maintain a legacy system using ASP 3.0 for more than a year and that was pain. The most wonderful pastime was debugging: you will hardly find anything for the purpose today and will have to decript beautiful errors like in IIS log:

error '800a9c68'
Application-defined or object-defined error

Nevertheless, I can confirm that I managed to reuse client and server JScript. But this was code written by me who knew that it was going to be used on the server.

P.S. I would not recommend move that way. There are plenty templating frameworks which are familiar to those who write HTML and JavaScript.

查看更多
手持菜刀,她持情操
6楼-- · 2020-04-04 17:36

What exactly do you mean by

"A customer uses JavaScript with jQuery to create a complex website"

Half the point of jQuery is to make it easy for the developer to manipulate the DOM, and therefore add interactive enhancements to a web site. By running the Javascript on the server and only rendering HTML you will lose the ability to add these enhancements, without doing a round trip to the server (think WebForms postback model...ugh).

Now if what you really mean is the customer uses a site builder based on jQuery, why not have that tool output flat HTML in the first place?

查看更多
男人必须洒脱
7楼-- · 2020-04-04 17:46

Take a look at this technology. You can invoke scripts to run at server, at client, or both. Plus, this really implements the firefox engine on the server. Take a look at it.

Aptana's Jaxer is the first AJAX web server so far. I have not tryed it yet, but I will. Looks promising and very powerful.

查看更多
登录 后发表回答