Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
how to redirect to another page using google web script?

I made successful code to redirect to another page using web script just in case I add query string manually. like this [main url]?Page=Partial

the doGet code

  function doGet(e) {
    var template;
    var pageName = e.parameter.page === undefined ? "Index" : e.parameter.page;  
    if (pageName === "Index") {
      template = HtmlService.createTemplateFromFile(pageName);
    }else{
      var url = ScriptApp.getService().getUrl();
      var getPageUrl = url + "?page=" + pageName;
      template = HtmlService.createTemplateFromFile(pageName);
      template.url = getPageUrl;
    }

    return template.evaluate();
  }

but when I try to href using anchor element It never work

  function href(pageName){
      var url = ScriptApp.getService().getUrl();
      var fullPageUrl = url + "?page=" + pageName;
      return fullPageUrl;
  }

then I use this in Index.html like this

 <a href="<?= href('Partial') ?>"></a>

notes:
if I do inspect for the page and click the href link it works well, but clicking directedly never work and come back with a page with error Forbidden Error 403

clicking href link content, when inspect page, or changing url manually only the successful ways to redirect to another page. and it never works by clicking directly on the href element and it comes back instead with error Forbidden Error 403

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!