[英]Click button from another page - HTML
我需要做什么:
page.com/index有一個按鈕,此按鈕需要單擊page.com/PageWhereThereIsExample中的Example
<li class="filter" data-filter=".color-1"><a href="#0" data-type="color-1">Example</a></li>
是否可以“點擊”示例或使用URL的類似內容?
篩選器模板: https : //codyhouse.co/demo/content-filter/index.html
HTML是無狀態的,因此如果您想單擊索引上的按鈕,然后通過自動單擊Example重定向到PageWhereThereIsExample,則必須存儲應該以某種方式單擊按鈕的信息。 您可以使用GET參數或HASH將這些信息存儲在URL中。 但仍然在PageWhereThereIsExample上,您必須檢查URL,然后使用JavaScript模擬“點擊”。
索引頁鏈接:
<a href="page.com/PageWhereThereIsExample#0">Example</a>
PageWhereThereIsExample過濾器項:
<li class="filter" data-filter=".color-1"><a href="#0" data-type="color-1">Example</a></li>
使用jQuery的PageWhereThereIsExample JavaScript:
$(document).ready(function() {
var hash = window.location.hash;
if (hash) {
$('a[href="'+hash+'"]').click();
}
});
對問題的其他解釋可能是您想在兩個瀏覽器頁面/選項卡之間發送消息。 在這種情況下,我建議您看以下問題: 訪問瀏覽器中其他選項卡的內容 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.