i want to add credentials to window.open(url) in angular6

450 views Asked by At

Code output

i am having this issue in window.open below is code

  repourl:any='http://192.168.1.104/....'
 ngOnInit() {
 var params = {
  Username: 'd2kuser',
  Password: '****'};window.open(this.repourl);

Is there any way i can pass credential with widow open.

2

There are 2 answers

0
Sachin On BEST ANSWER
    form = document.createElement("form");
   form.action = url;
   form.method = verb;
   form.target = target || "_blank";
   if (_data) {
       var data = _data.split("&")
       for (var key = 0; key < data.length; key++) {
           var input = document.createElement("textarea");
           input.name = data[key].split("=")[0];
           input.value = data[key].split("=")[1];
           form.appendChild(input);
       }
   }
   form.style.display = 'none';
   document.body.appendChild(form);
   form.submit();

use different approach for same , submitted form action

0
M Danial On

Add Username and Password as queryparams in URL. It will work.