使用$ window.open在新标签中打开HTML文本 [英] Open html text in new tab using $window.open

查看:1819
本文介绍了使用$ window.open在新标签中打开HTML文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$window.open('<span>request processed successfully</span>', '_blank');

我想 $窗口服务以显示简单的文本要求在新标签中成功处理。

I would like the $window service to show the simple text request processed successfully in a new tab.

但不是它,它把HTML文本的位置URL,并尝试打开网页的http://域的地址#请求成功处理

But instead of it, it treats the html text as location url and tries to open the page http://domain-addr#request processed successfully

我如何可以通过HTML文本参数角的 $窗口服务?

How can i pass html text argument to angular's $window service?

推荐答案

您可以做标准的JavaScript这样的事情...

You can do something like this in standard JavaScript...

function newWindow() {
    // create some html elements
    var para = document.createElement('p');
    var title = document.createElement('title');

    // define some window attributes
    var features = 'width=400, height=400, status=1, menubar=1, location=0, left=100, top=100';
    var winName = 'New_Window';

    // populate the html elements
    para.textContent = 'Some example text.';
    title.textContent = 'New Window Title';

    // define a reference to the new window
    // and open it with defined attributes
    var winRef = window.open('', winName, features);

    // append the html elements to the head
    // and body of the new window
    winRef.document.head.appendChild(title);
    winRef.document.body.appendChild(para);
}

这篇关于使用$ window.open在新标签中打开HTML文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆