javascript - 当用户单击 webform 弹出链接时,根据位置将用户重定向到特定网站
问题描述
我们在网站上有一个链接。
当用户点击链接时,它会弹出一个在线表格。
客户希望,如果来自美国以外的用户点击该链接,用户会被重定向到另一个网站。
这是可行的吗?
网站基于最新的 Drupal 8 版本,以防万一有一个模块可以做到这一点。
解决方案
您可以像这样使用表单使用 hook_form_ID_alter。
function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
// get the IP address of user and determine where they are coming from
// Follow this https://stackoverflow.com/questions/12553160/getting-visitors-country-from-their-ip
// Redirect user
// Follow this https://drupal.stackexchange.com/questions/146185/how-to-create-a-redirection-in-drupal-8
}
推荐阅读
- c# - 发送 TCP 数据包
- vba - Excel_VBA 突出显示具有当前日期和不同时间的单元格
- javascript - Angular6地图不存在
- python - 导入数据集时如何随机复制一些文档?
- mysql - 想从mysql db中的电话号码获取国家区号
- python - Jupyter Notebook 和 JupyterLab 有什么区别?
- javascript - 如何在angularjs中获取url参数?
- javascript - 如何使用javascript查找数组中的所有值是否相等
- php - Cake PHP 2.X 设置邮件发送时的异常处理
- python - Python,pip:安装过程中避免使用 gcc