[英]how to show/hide the single element when coming from different pages?
我有2個頁面,分別為“ A”和“ B”,兩個頁面都有一個鏈接,將打開同一頁面“ X”。 但是頁面“ X”將根據其從哪個頁面顯示/隱藏一些組件。
在頁面“ X”上,我想顯示/隱藏名為“ X”的頁面上的按鈕。
如果我來自“頁面A”>,則它們應該可見。
如果我來自“頁面B”>,則它們應該不可見。
==========================================
我正在采取的方法是通過在頁面A和B上的URL中傳遞變量/值。
HTML代碼頁A:-
<a data-fancybox-type="iframe" class="various marginLeft10 button" href="/Provision/Summary/MC-IT0401-ATUTEJA?abc">View Summary</a>
HTML代碼頁B:-
<a class="marginLeft50 button" href="/Provision/Summary/MC-IT0401-ATUTEJA?xyz">Confirm & Proceed</a>
X頁代碼=
<div class="marginTop50 marginBottom valignBottom" role="button" id="summaryButtons">
<input type="button" class="active" value="Back" id="stepSummaryBack">
<input type="button" class="bigButton marginLeft50" value="Ready for Diagnostic" id="stepSummaryConfirm">
</div>
該特定Div應按照“ A”或“ B”頁面的導航顯示/隱藏。
我現在不確定如何使用jquery傳遞“ href”以及如何確認URL和變量( ?abc和?xyz )。
請提出建議。
並且讓我知道是否有不清楚的地方或需要更多詳細信息。
因此,在onload事件中,您可以這樣做。
var URL = window.document.URL.toString();
var vars = URL.split("?");
then your variable should be vars[1];
我建議在渲染Page X時處理顯示/隱藏決策,而不是在已加載的javascript中處理。 您無需在網址中使用查詢參數( ?abc
和?xyz
)。 從控制器中的Page X請求訪問HTTP_REFERER
以查看該請求是來自/page_a
還是/page_b
,然后在渲染Page X時使用該信息來確定是否包括按鈕。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.