繁体   English   中英

URL共享传递参数

[英]URL share passing parameters

我确实花了两个多小时试图找到一个简单的答案,但不幸的是我没有。

问题的情况:

  1. 用户浏览到ulan.be ,选择3个参数并继续。

  2. 该页面将他重定向到类似此处的内容

  3. 用户希望通过社交共享按钮(例如电子邮件或Whatsapp)与其他用户共享此内容,但是URL被剪切并且参数未传递。

基本上,我需要一个Wordpress插件或基本的JS代码来为第二个用户启用“复制地址栏”。

任何帮助表示赞赏-谢谢。

这是我处理这种简单逻辑的方法:

 var sel = document.querySelector("#ddlViewBy"); var input = document.querySelector("input#location"); var button = document.querySelector("button"); var param1 = ''; var param2 = ''; button.addEventListener("click", function(evt){ param1 = sel.options[sel.selectedIndex].value; param2 = input.value; //Just to check the value //alert(param1 + ", " + param2); }); //Then reconstruct your URL bar with the params above /** * orig_url = window.location.href; * window.location.href = orig_url + '?city=' + param1 + '&zip=' + param2 * **/ 
 <select id="ddlViewBy"> <option value="1">test1</option> <option value="2" selected="selected">test2</option> <option value="3">test3</option> </select> <input type="text" id="location" placeholder="Location" /> <button type="button">Submit</button> 

我希望这有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM