简体   繁体   English

基于单击的动态URL

[英]Dynamic URL based on button clicked

My question might seem a bit ambiguous but you should understand what I mean first. 我的问题似乎有点模棱两可,但您首先应该明白我的意思。

I want to be able to generate dynamic URLs on the fly so that when a link (x link) is clicked on a parent page, it should move to a 'node' page which then decides to move to the 'x' page corresponding to the link clicked on the parent page. 我希望能够动态生成动态URL,以便在父页面上单击链接(x链接)时,它应该移至“节点”页面,然后决定移至与之对应的“ x”页面链接在父页面上单击。

For eg - 例如-

  1. Parent page has 5 links (a, b, c, x, y) 父页面有5个链接(a,b,c,x,y)
  2. User clicks on 'b' 用户点击“ b”
  3. User is led to Node Page which plays a video and automatically (after the video ends) redirects to Page 'b' (js to simulate click below) 引导用户进入播放视频的节点页面,并自动(视频结束后)重定向到页面“ b” (模拟下面的js的js)

Is there a mechanism where the Node page can detect the link clicked on the parent page and lead the user to the corresponding page ID defined on the parent page? 是否存在一种机制,“节点”页面可以检测在父页面上单击的链接并将用户引导到在父页面上定义的相应页面ID? See Image below - 参见下图- 在此处输入图片说明

I already have implemented the automatic progression from the Node page using JS below which leads the user to the next page after 15.5 seconds - 我已经使用下面的JS从Node页面实现了自动进度,它在15.5秒后将用户引导至下一页-

<script>
    $("document").ready(function() {
        setTimeout(function() {
            $(".proceed").trigger('click');
        },15500);
    });
</script>

What I need to know is that based on the link clicked on the parent page, can the Node Page decide where to lead the user next? 我需要知道的是,基于在父页面上单击的链接,节点页面可以决定下一步将用户引向何处?

Also, this HTML package is to be used on an e-detailing platform running on iOS for the iPad which in my experience allows most of HTML, CSS & JS/jQuery. 另外,此HTML软件包将在iPad的iOS上运行的电子详细平台上使用,根据我的经验,该平台允许使用大多数HTML,CSS和JS / jQuery。

Thanks in advance 提前致谢

Try something like that 试试这样的东西

<a class="mylink" data-url="a.html">A</a>
<a class="mylink" data-url="b.html">B</a>

<script>
var url = "";
$(".mylink").click(function(){
url=$(this).data("url");

//Here your function who start your video
playvideo();
});

//Here function trigger when your video is finish
function videoIsFinish()
{
   if(url!="")
      window.location.href=url;

}

</script>

This is very much doable. 这是非常可行的。 Just use a javascript switch statement ( see here ) and pass the case value using the url the user clicks ( see here ). 只需使用javascript switch语句( 请参阅此处 ),然后使用用户单击的URL传递大小写值( 请参阅此处 )。

Have the switch statement on the node page that can then pass you on to the desired destination page using JavaScript. 在节点页面上具有switch语句,然后可以使用JavaScript将您转到所需的目标页面。

This can be easily achievable, first you can use any global variables and then assign the value to the variable. 这很容易实现,首先可以使用任何全局变量,然后将值分配给该变量。

var url = window.location.href;

Then on the node page you can check the value of the url variable, navigate to the page according to that. 然后,在节点页面上,您可以检查url变量的值,并根据其导航到该页面。 Other solution is you can use document.referrer to get the previous url. 其他解决方案是您可以使用document.referrer来获取先前的URL。 Then do the same checking according to it. 然后根据它进行相同的检查。

var url = document.referrer;

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

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