简体   繁体   中英

How to Change “to-markdown.js” So it Will Run as Server Side JScript

I am trying to wrap a javascript in <script type="javascript" runat="server"> ... </script> tags so that I can access it from vbScript/classic asp.

Normally this works fine, but I think there is something in the script I am trying to use that isn't compatible with jScript, but I am not sure how to change it so that it just works.

The js I am trying to use is here: https://github.com/domchristie/to-markdown/blob/master/dist/to-markdown.js

The error i am seeing in jScript is :

Microsoft JScript runtime error '800a01b6'
Object doesn't support this property or method
/bfadmin/markdown/h2m.asp, line 583

...line 583 is this line of the source javascript:

Object.keys(voidElements).forEach(function (name) {

I am not trying to use any of the extenstions... so if those are whats causing the issue, they could be removed. I am just not sure what to remove in order to use it.

Is what I am trying to do possible and if so, how must the js be changed to work as jscript.

Array.forEach is an ECMAScript 5 method, and server-side JScript is generally ECMAScript 3. One way to get around this without modifying the script you're including is by using a polyfill, such as the one from the MDN documentation I linked to. More generally, there are polyfill libraries out there that add mostly-compatible ECMAScript 5 methods to ECMAScript 3 environments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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