为什么在新打开的窗口中看不到glyphicon图标?

麦可

我在$ window.open命令的帮助下打开新窗口,并将html内容写入该窗口。

这是Javascript代码:

var test = angular.module('test', []);

test.controller('testController', ['$compile', '$scope','$window', function($compile, $scope, $window) {
    $scope.openWindow = function() {
       $window.open('', '_blank', 'width=500,height=400').document.write($("#report").html());
    };}]);

这是我写到新窗口的内容:

<div ng-app="test" id = "report" ng-controller="testController">
 <p>Envelope icon: <span class="glyphicon glyphicon-envelope"></span></p>
<p>Search icon: <span class="glyphicon glyphicon-search"></span></p>
<p>Print icon: <span class="glyphicon glyphicon-print"></span></p>
<hr/>
    <button ng-click="openWindow()">push!</button>
</div>

这是工作的小提琴

问题是我在新打开的窗口中看不到glyphicon图标。

知道为什么我看不到glyphicon图标吗?

更改Simo

您的代码中有两个错误。首先,您没有正确包含CSS。您应该使用href属性而不是rel属性来包含css。其次,integrity如果您要从外部包含引导程序,则必须使用密钥检查。

正确的包含是:

var test = angular.module('test', []);

test.controller('testController', ['$compile', '$scope','$window', function($compile, $scope, $window) {
    $scope.openWindow = function() {
    var content = $("#report").html();

    var html = '<html><head><title>hi</title><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"></head><body>'+content+'</span></p></body></html>'   

       $window.open('', '_blank', 'width=500,height=400').document.write(html);                         
    };}]);

和更新的小提琴:http : //jsfiddle.net/d8atdw0t/283/

如果您希望从项目中引用样式表,则可以加载带有查询参数(如)的页面模板http://yoursite.com/page.html?window=true,然后在$window加载时指定带有查询参数的url。

$window.open('http://yoursite.com/page.html?window=true', '_blank', 'width=500,height=400');

如果存在查询参数,则可以限制加载模板文件的方式(例如,从后端),从而可以加载模板文件。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为什么在主窗口中看不到绿色矩形?

在打开的窗口中看不到所有内容

为什么我在 Fabric 中看不到我的 android 应用程序图标?

为什么我在操作栏中看不到默认图标?

为什么我在GNOME顶部栏中看不到网络管理器图标?

为什么在文件描述符中看不到进程打开的端口?

为什么在TFS中看不到分支树?

为什么在C#中看不到Ping类?

为什么在SSMS结果列表中看不到全名?

为什么在图形绘制中看不到弯曲的边缘?

为什么在 QGraphicsScene 中看不到 QGraphicsWidget 的选择边框?

为什么在PowerShell中看不到脚本的参数?

为什么在UIScrollView中看不到UIStackView?

为什么我在gdb backtrace中看不到行号?

为什么在Swift中看不到图像?

为什么在Nautilus中看不到缩略图?

为什么我的GridView对象在代码中看不到?

为什么在cloudboost中看不到我的表?

为什么模块在引擎代码中看不到类?

在Chrome中看不到窗口大小

在调试窗口中看不到正在运行的任务-Visual Studio 2019

在 IntelliJ 社区版的“结构”窗口中看不到 Javascript 函数或变量

将shapefile导出到SVG-但在浏览器窗口中看不到

设置清单后,为什么我看不到图标?

为什么在新的Unity5中Rigidbody2D中看不到“固定角度”选项?

为什么我看不到tortoiseHG的新分支?

在SlateJS工具栏中看不到图标

在iPad中看不到应用程序图标

为什么我的SelectionGrid在Unity Editor中看不到GameObject?