如何在javascript中通過url傳遞變數?
const readMultipleNodesFromDatabase = (buyerId,sellerId) => {
var buyer_id = buyerId;
var seller_id = sellerId;
var chatId = buyer_id '_' seller_id;
firebase
.database()
.ref("Message/" chatId)
.once("value", function (snapshot) {
// $fetchdata = snapshot.val();
window.location.href = "<?php echo $module_site_url .'/add';?>";
});
};
我如何通過該網址發送chatId?
uj5u.com熱心網友回復:
不知道我是否理解正確,但
window.location.href = `<?php echo $module_site_url .'/add';?>?chatid=${chatId}`
uj5u.com熱心網友回復:
您可以將聊天 id 作為 url 中的 queryString 發送,然后在需要使用它的頁面上獲取 querystring 值
var chatId = buyer_id '_' seller_id;
window.location.href = "<?php echo $module_site_url .'/add?chatid=' chatId;?>";
然后您可以使用 location.search ( https://developer.mozilla.org/en-US/docs/Web/API/Location/search )從目標頁面上的 teh url 檢索它
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/464640.html
標籤:javascript
