zoukankan      html  css  js  c++  java
  • vue项目中嵌套外部网页

    主要有两种方法:

    一、通过接口请求,然后v-html渲染,这种方法试验之后发现不行,v-html不会渲染内部页面

    二、iframe的方式(解决引入成功之后获取不到引入的标签问题及跨域问题

    需要嵌套的网页地址为:http://10.108.230.74:8080/smartbi/vision/openresource.jsp

    config.js文件中设置代理:

    dev: {
        env: require('./dev.env'),
        host: '0.0.0.0',
        port: '8080',
        autoOpenBrowser: true,
        assetsSubDirectory: 'static',
        assetsPublicPath: '/',
        proxyTable: {
          '/jsp': {
            target: 'http://10.108.230.74:8080', // 接口地址
            changeOrigin: true, // 是否跨域
            pathRewrite: { // 转发
                '^/jsp': ''
            },
            secure: false,
            headers: {
              Referer: 'https://10.108.230.74:8080'
            }
          },
        },

    备注:代理里面https的url才需要加headers的参数

    在页面引入:

    <iframe src="jsp/smartbi/vision/openresource.jsp" width="100%" height="800" frameborder="0" scrolling="auto" id="iframename" name="iframename"></iframe>

    获取iframe页面里某个标签

    var i = document.getElementById('iframename');
    i.onload = function(){
    console.log(i.contentWindow.document)
    console.log(i.contentWindow.document.getElementsByClassName("login-user-input"))
    }

  • 相关阅读:
    郁闷的Alexa破10万。
    回到杭州,2009开始了。
    美剧。
    英来网招聘:兼职js开发。(补充)
    村姑的Beta 2.0,TT。
    爆牙齿的Web标准面试考题II(iPhone SMS/iChat UI的Web标准实现)
    天使飞来。
    Web标准的未来,浏览器的未来,应用的未来。
    咖啡厅与产品形态。
    学习使用笔和纸。
  • 原文地址:https://www.cnblogs.com/www3j/p/13093393.html
Copyright © 2011-2022 走看看