我正在尝试添加Unity3D (www.unity3d.com)网络播放器到我的网站与SilverStripe的内容管理系统版本2.4.5。似乎发生的情况是,SS正在动态地删除我的包含web播放器的代码。它会留下一个结束的div标签。
对于一个简单的静态页面来说,嵌入web播放器是非常简单的。您需要以下代码,它可以完美地工作。HTML:
<script type="text/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js"></script>
<script type="text/javascript">
<!--
//gets the unityPlayer div and replaces the content with an embed tag which is the web player made by Unity (it works outside of SS.)
function GetUnity() {
if (typeof unityObject != "undefined") {
return unityObject.getObjectById("unityPlayer");
}
return null;
}
//sets the parameters of the web player
if (typeof unityObject != "undefined") {
unityObject.embedUnity("unityPlayer", "MazePuzzle.unity3d", 720, 450);
}
-->
</script>
<div id="unityPlayer">
<div class="missing">
<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
</a>
</div>
</div>发布于 2011-04-13 16:07:26
在内容域中插入javascript被认为是不好的做法,这就是为什么wysiwyg编辑器会删除script元素的原因。不过,你可以通过配置tinymce来解决这个问题(有关如何做的更多信息,请参阅this thread )。
更好的方法可能是使用silverstripe 2.4+中支持的短码。您可能会在编辑器中看到类似以下内容:
unity width=720高度=450MazePuzzle.unity3d/unity
关于短码的docs有点稀疏,但你可以在ssbits上找到一个很好的教程
https://stackoverflow.com/questions/5629633
复制相似问题