好吧,由于我的条件,我修复它的方式非常容易(我不需要views.py 中的任何参数)。
所以我所做的是在我的 IFrame html 页面中我这样做了
window.onload = function () {
con_port = "?port=" + WebUtil.getQueryVar('con_port', null);
在 ExtJS 中我做了这个
var noVNC = Ext.create('Ext.panel.Panel', {
title: "noVNC",
frame: false,
title: false,
width: '100%',
height: '100%',
layout: 'fit',
items: [{
xtype: "component",
autoEl: {
tag: "iframe",
src: "/noVNC?con_port=5901"
}
}]
});
现在我只是硬编码在端口号中,但您可以将端口号添加到字符串中,如下所示
src: "/noVNC?con_port=590" + port
views.py
def noVNC(request):
return render(request, 'noVNC_Auto.html', content_type='text/html')
urls.py
urlpatterns = patterns('',
url(r'^$', 'kfe.views.index'),
url(r'^index$', 'kfe.views.index'),
url(r'^noVNC$' , 'kfe.views.noVNC'),