Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

$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

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

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...