Anchor link to app with parameters, google apps sc

2019-02-21 03:38发布

问题:

I have the following anchors in my html template:

<a href="<?!= ScriptApp.getService().getUrl() ?>"><button>All Feedback</button></a>
<a href="<?!= ScriptApp.getService().getUrl()+"&filter=bomgar" ?>"><button>Bomgar Feedback</button></a>
<a href="<?!= ScriptApp.getService().getUrl()+"&filter=tickets" ?>"><button>Ticket Feedback</button></a>

When navigating to the links with parameters, the "&" and "=" symbols are %26 and %3d in the url. Is there a way to prevent this from happening ?

Thanks

回答1:

To add GET parameters to a URL, you should use the ? character to introduce them (instead of the & character). The ampersand is used to add multiple variables. So your URL should look like this.

http://script.google.com/[.......]/exec?variable=data&otherVariable=otherData

So since you didn't have the ?, the URL was sanitized to eliminate those characters.

This web app that I made illustrates the difference.

<a href="<?= ScriptApp.getService().getUrl()+"?filter=bomgar" ?>"><button>Bomgar Feedback</button></a>