最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ExtJS 4.1 load content from external web page - Stack Overflow

programmeradmin6浏览0评论

I've a Ext.panel.Panel and I would load content from an external web page into my panel.

I've tried to use the loader as described here: loader question

and you can found an example in this jsfiddle: /

Ext.require([    
'Ext.form.*',
'Ext.tip.*'
]);


Ext.onReady(function() {    


Ext.QuickTips.init();

Ext.create('Ext.panel.Panel',{
renderTo: Ext.getBody(),
height:400,
    width:400,
    id:'specific_panel_id'
});

dynamicPanel = new Ext.Component({
       loader: {
           /*load contents from this url*/
          url: '',
          renderer: 'html',
          autoLoad: true,
          scripts: true
          }
       });

 Ext.getCmp('specific_panel_id').add(dynamicPanel);

});

Probably I haven't understood how to use loader (if it is possible) with external web pages. So my first question is: Is it possible to load the page into my panel using loader?

The second question: If the answer is "no" how do you suggest to load the content of that page?

Thank you all

I've a Ext.panel.Panel and I would load content from an external web page into my panel.

I've tried to use the loader as described here: loader question

and you can found an example in this jsfiddle: http://jsfiddle/eternasparta/sH3fK/

Ext.require([    
'Ext.form.*',
'Ext.tip.*'
]);


Ext.onReady(function() {    


Ext.QuickTips.init();

Ext.create('Ext.panel.Panel',{
renderTo: Ext.getBody(),
height:400,
    width:400,
    id:'specific_panel_id'
});

dynamicPanel = new Ext.Component({
       loader: {
           /*load contents from this url*/
          url: 'http://it.wikipedia/wiki/Robot',
          renderer: 'html',
          autoLoad: true,
          scripts: true
          }
       });

 Ext.getCmp('specific_panel_id').add(dynamicPanel);

});

Probably I haven't understood how to use loader (if it is possible) with external web pages. So my first question is: Is it possible to load the page http://it.wikipedia/wiki/Robot into my panel using loader?

The second question: If the answer is "no" how do you suggest to load the content of that page?

Thank you all

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Aug 19, 2013 at 9:36 MarcoMarco 1,3344 gold badges17 silver badges41 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 12

For external content, you will have to use an iframe. However if you want that iframe's dimensions to be managed by its container panel, you'll have to make it a ponent instead of just using html property:

Ext.define('MyIframePanel', {
    extend: 'Ext.panel.Panel',
    layout: 'fit',
    items: [{
        xtype: 'box',
        autoEl: {
            tag: 'iframe',
            src: 'http://it.wikipedia/wiki/Robot',
        },
    }]
});

See also an example with a Window and dynamic page loading in my recent blog post: http://nohuhu/development/using-render-selectors-to-capture-element-references/.

It is a security reasons (Access-Control-Allow-Origin).

You can just set "html" property of your panel as:

html: '<iframe src="http://it.wikipedia/wiki/Robot"></iframe>',

See: http://jsfiddle/sH3fK/2/

If you load the page from the same domain, you can just set "loader" property of your panel:

Ext.create('Ext.panelPanel', {
    ...
    loader: {
        url: 'content.html', //<-- page from the same domain
        autoLoad: true
    },
    renderTo: Ext.getBody(),
    ...
});
发布评论

评论列表(0)

  1. 暂无评论