Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

javascript - Open html text in new tab using $window.open

$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.

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...