[英]form action to direct to a new html page is not working
我有一个产品搜索结果页面(html1文件),我希望能够单击任何一种产品,然后定向到产品详细信息页面(Product_overview.html)。
产品结果由此firebase代码生成
var itemdetailref = Cataloguedatabase.ref('/Listings/');
return itemdetailref.once('value').then(function(snapshot){
snapshot.forEach(childSnapshot => {
let key = childSnapshot.key;
//use ES6 includes function
if(key.includes(searchcontent)){
var searchresults = childSnapshot.val();
var container = document.getElementById("searchcontainer");
var productcard = `
<div action='../html/Product_overview.html' class="product" id="${key}" method='GET' onclick="showdetail(this);" name="product-view" role="search">
<div class="img-container">
<img src=${searchresults.ProductImageUrl}>
</div>
<div class="product-info">
<div class="product-content">
<span class="button" id="price">${searchresults.Price}</span>
</div>
</div>
</div>`
container.innerHTML += productcard;
} else {
console.log("No match was found");
}
});
})
然后是检查本地存储的功能
function showdetail(element){
var productID = element.id;
alert(productID);
var currentUrl = window.location.href;
url = currentUrl + encodeURIComponent(productID);
document.location.href = url;
}
当我单击产品div时,它不会在div操作中将页面重定向到Product_overview.html。 我试图将div更改为没有任何变化的形式。 我做错了什么,该如何解决?
action属性仅适用于form元素。 您可以将表格嵌套在div内,也可以将锚标记指向所需的网址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.