如何编辑在iframe中呈现的页面的CSS

时间:2019-01-19 18:46:24

标签: javascript jquery html css iframe

我是iframe的新手。我创建了一个HTML页面,并渲染了其他域的页面。我想在Iframe中更改呈现页面的CSS。是否可以更改在iframe中呈现的任何元素的css属性。 如果是,请提出建议。

我的代码在这里

   <html> 
<head> 
<meta name="viewport" content="width=device-width, initial-scale=1.0, 
maximum-scale=1.0, user-scalable=0"> <title>health score</title> <style 
type="text/css"> html{ margin: 0; height: 100%; overflow: hidden; } iframe{ 
position: absolute; left:0; right:0; bottom:0; top:0; border:0; }
</style>
</head> <body>
<iframe id="iframeId" name="iframeName"width="100%" height="100%" 
frameborder="0"  >  
</iframe> 
<script type="text/javascript" 
src="https://otherdomain.com/somejs.js">
</script> <noscript>
 <iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXX" height="0" 
 width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new  
Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-XXXX');</script>
  <script type="text/javascript">
     var url_string = window.location.href;
     var url = new URL(url_string);
     var querystrId= url.search.split("=")[1]
     var urlToRedirect = "https://otherdomain.com/somepage.html?enquiryid="+ querystrId;

     var getUrl = document.getElementById("iframeId");
     var setUrl = getUrl.setAttribute("src", urlToRedirect); 


  </script>
   </body> </html>
    <script> (function() { 

      var qs, js, q, s, d = document,
        gi = d.getElementById,
        ce = d.createElement,
        gt = d.getElementsByTagName,
        id = "irameId",
        b = "https://otherdomain.com/";
    if (!gi.call(d, id)) {
        js = ce.call(d, "script");
        js.id = id;
        js.src = b + "somejs.js";
        q = gt.call(d, "script")[0];
        q.parentNode.insertBefore(js, q)
    }


  })() </script>

0 个答案:

没有答案