How can I trigger JavaScript in a VRML Anchor—is it possible to use an Event Listener?

 ̄綄美尐妖づ 提交于 2020-02-26 00:53:49

问题


I'm using the X_ITE javascript-WebGL library to display a legacy VRML project in modern browsers.

Anchors in the VRML code currently open HTML files in separate windows (on the same domain) like this:

Anchor {
  url "javascript: window.open('./data/583.html' other_stuff…)"
  description etc.…
}

or by calling a function and passing the relevant argument:

  url "javascript: showInfo('583')"

Both produce CORS errors, which I can get around by simply opening the URL:

  url "data/583.html"

However, instead of a "back" link from that page to the model (and page reload) I want to present the content in a modal (or something) on the same HTML page, but the CORS issue remains even with a simple call to console.log():

url "javascript: console.log('hello');

What would be the best approach to this? The codebase is here and here's the file I'm looking at.

Ideally, I'd like to know if it's possible to add an event listener to a VRML element as you can in X3D? If not, how do I handle the CORS issue with url "javascript: …?

来源:https://stackoverflow.com/questions/60027233/how-can-i-trigger-javascript-in-a-vrml-anchor-is-it-possible-to-use-an-event-lis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!