JavaScript indexOf() 函数在 VB.Net 中失败

JavaScript indexOf() function fails in VB.Net

此代码在大多数 (全部?) 浏览器中运行良好:

    myDate = new Date();
    alert(myDate.toString().indexOf("("));

但是,当在 VB.Net WebBrowser 控件中执行时,它 returns -1.

这是为什么?

Why is that?

DatetoString 不需要输出其中包含任何 ( 的字符串。如果字符串中没有 (indexOf 将 return -1.

来自 the specification:

  1. Let O be this Date object.
  2. If O does not have a [[DateValue]] internal slot, then
    • Let tv be NaN.
  3. Else,
    • Let tv be this time value.
  4. Return ToDateString(tv).

...其中 ToDateString 表示:

  1. Assert: Type(tv) is Number.
  2. If tv is NaN, return "Invalid Date".
  3. Return an implementation-dependent String value that represents tv as a date and time in the current time zone using a convenient, human-readable form.

所以可以不使用时区指示符,或者 Z 来指示 GMT,或者不使用 (...) 的时区指示符,例如 GMT+04:00-05:00 或类似的,等等.