Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在web2py中包含静态javascript_Javascript_Html_Web2py - Fatal编程技术网

在web2py中包含静态javascript

在web2py中包含静态javascript,javascript,html,web2py,Javascript,Html,Web2py,我有这个html代码。它很好用。但是,我希望在web2py视图中使用相同的代码。考虑到web2py中有一种特定的处理源文件的方法,请帮助我使其在web2py中工作。在my post.html布局视图中,我尝试使用: {{response.files.append(URL(“”))} ' 变量编辑器; window.onload=函数(){ editor=com.wiris.jsEditor.jsEditor.newInstance({'language':'en'}); editor.inser

我有这个html代码。它很好用。但是,我希望在web2py视图中使用相同的代码。考虑到web2py中有一种特定的处理源文件的方法,请帮助我使其在web2py中工作。在my post.html布局视图中,我尝试使用:

{{response.files.append(URL(“”))}

'
变量编辑器;
window.onload=函数(){
editor=com.wiris.jsEditor.jsEditor.newInstance({'language':'en'});
editor.insertInto(document.getElementById('editorContainer');
}
'

在需要编辑器的任何操作的视图中,您可以执行以下操作:

{{extend 'layout.html'}}
<script src="http://www.wiris.net/demo/editor/editor"></script>
<script>
    var editor;
    window.onload = function () {
        editor = com.wiris.jsEditor.JsEditor.newInstance({'language': 'en'});
        editor.insertInto(document.getElementById('editorContainer'));
    }
</script>

另外,请注意,在这种情况下,您不能使用
response.files
,因为文件名不是以
.js
结尾的,但是为了将来参考,您不应该将
URL()
函数与外部URL一起使用——它只用于生成web2py内部URL。

。谢谢你的回复。我一直在尝试你分享的东西,但仍然不起作用。文本框(editorContainer)仍然不会呈现wiris编辑器。我缺少什么吗?很抱歉,在本例中不能使用
response.files
,因为文件名不是以
.js
结尾。因此,要么将文件复制到您自己的静态文件夹中,并为其提供
.js
扩展名,要么手动编写
标记。更新了答案以反映这一点。Anthony感谢我找到了答案,因为URL结尾不是.js,Web2py无法理解它是一个js文件。因此,它无法正确加载该文件。web2py还要求URL是安全的。在一天结束时,我使用了:wiris.net/demo/editor/editor#editor.js“>。我确信这不是最好的解决方案,但这是一个开始。web2py不要求URL是安全的,但是如果您的web2py页面是通过HTTPS提供的,那么默认情况下,如果您试图通过HTTP加载某些内容,大多数浏览器都会抱怨。您的解决方案似乎是合理的。
{{extend 'layout.html'}}
<script src="http://www.wiris.net/demo/editor/editor"></script>
<script>
    var editor;
    window.onload = function () {
        editor = com.wiris.jsEditor.JsEditor.newInstance({'language': 'en'});
        editor.insertInto(document.getElementById('editorContainer'));
    }
</script>
{{include 'wiris_js.html'}}