Anchor link to app with parameters, google apps script

為{幸葍}努か 提交于 2019-12-01 13:45:58

问题


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>


来源:https://stackoverflow.com/questions/14733831/anchor-link-to-app-with-parameters-google-apps-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!