Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to redirect it to homepage instead of showing this in new tab. #67

Open
FutureUltron opened this issue Jun 30, 2023 · 1 comment
Open

Comments

@FutureUltron
Copy link

{"result":"success","row":2}

How to redirect it to homepage instead of showing this in new tab.
Screenshot 2023-07-01 at 00 12 10

@bbowers-hawaii
Copy link

bbowers-hawaii commented Jul 15, 2023

What worked for me was:

  1. set the Web App access/auth, "Who has access" to Anyone.
    you can do this in appscript by clicking Deploy, Manage Deployments, edit

  2. then in your html file after closing tag.

<script>
window.addEventListener("load", function() {
  const scriptURL = '<YOUR SCRIPT URL>'
  const form = document.getElementById('id of your form');
  form.addEventListener("submit", function(e) {
    e.preventDefault();
    const data = new FormData(form);
    fetch(scriptURL, {
      method: 'POST',
      body: data,
      mode: 'no-cors', // unsure if this is needed since access changed to anyone
    })
    .then(() => {
    window.top.location.href = 'your page url';
    })
  });
});
</script>	

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants