我找到了要打印的解决方案:
function Print() {
if (document.queryCommandSupported('print')) {
document.execCommand('print', false, null);
}
else {
window.parent.<framename>.focus();
window.print();
}
}
尽管我有几个iframe,而不只有一个。对于多个iframe,最好的书写方式是什么?
答案 0 :(得分:0)
我认为document.execCommand('print',false,null)与window.print()方法类似,您可以使用其中任何一个来打印整个页面。
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<select id="nameField" class="form-control" ng-model="selectedOption" ng-change="fillDataType()" ng-options="obj.name for obj in userDefinedWorkflowVariables">
</select>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.selectedOption={};
$scope.userDefinedWorkflowVariables = [{name:"object1",dataType:"number",description:"description1"},
{name:"object2",dataType:"number",description:"description2"}]
$scope.selectedOption =$scope.userDefinedWorkflowVariables[0]
$scope.fillDataType = function() {
console.log( $scope.selectedOption)
var dataType = $scope.selectedOption.dataType;
}
});
</script>
</body>
</html>