I am writing one lightning component for JavaScript button. Can you please tell me how can we replace below code blocks in lightning?

window.open('test.html', 'formresult', 'scrollbars=yes, menubar=no, height=700, width=1250, resizable=yes, toolbar=no, status=no');


2 Answers 2


Most likely you are looking for this "force:navigateToURL" https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_navigateToURL.htm

  • Hi Roman, Thanks for your reply. Actually we can't go with NavigateToURL option as in our case we don't have any URL with us to populate. Through our javascript button we are sending one hidden attributes (Username and Password) to third party and whatever response we are getting from third party, that response we are trying to open as URL. I hope you understood the requirement. So do we have any option in lightning to cope up with this?
    – user46367
    Commented Jul 13, 2017 at 7:48
  • Hi, if you can please share a code, and state a part where it is not working for you in lightning.
    – Roman
    Commented Jul 13, 2017 at 8:24

Please find below piece of JavaScript code where I got stuck.

if(QSName!='' && QSValue!=''){
// Creating a form to send the MagicToken and UserID as a hidden attribute to send it as POST instead of GET
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", domain);
form.setAttribute("target", "formresult");

// Setting the attribute for MagicToken and its Value
var hiddenFieldMT = document.createElement("input");
hiddenFieldMT.setAttribute("type", "hidden");
hiddenFieldMT.setAttribute("name", QSName);
hiddenFieldMT.setAttribute("value", QSValue);

// Setting the attribute for UserID
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "u");
hiddenField.setAttribute("value", userId);
//alert('URL is :: ' + url + '&' + userId);

window.open('test.html', 'formresult', 'scrollbars=yes,menubar=no,height=700,width=1250,resizable=yes,toolbar=no,status=no');


NOTE: Here through window.open(), we are opening one popup and through form.submit() submitting credentials to third party. Afterwards we are opening response from third party in that popup.

  • can you tell me how to open a popup window on button click, in the lightning component. I want to display a visualforce page
    – SFDC
    Commented May 9, 2018 at 9:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .