當用window.open打開時,你可以添加你的參數作爲通用獲取參數。即:
window.open(「mysite.com/page.php?param=123」);
然後在page.php文件就可以讀取參數值的方式:
$param = $_GET['param'];
更新:
如果你想POST請求,您可以添加(隱藏)表格形式字段包含您想要傳遞的值並從代碼提交該表單。喜歡的東西:
<form id="TheForm" method="post" action="test.asp" target="TheWindow">
<input type="hidden" name="something" value="something" />
<input type="hidden" name="more" value="something" />
<input type="hidden" name="other" value="something" />
</form>
<script type="text/javascript">
window.open('', 'TheWindow');
document.getElementById('TheForm').submit();
</script>
Window.open and pass parameters by post method
你是如何將查詢發送到PHP?使用Ajax或表單? – Manngo
通過ajax發送此值到同一頁面或不同的php頁面並使用$ _POST獲取該值(使用ajax post方法) –
Manngo:我不使用Ajax或表單,只使用簡單的查詢,然後使用mysqli_query獲取結果。 活着死:我怎樣才能在window.open方法中使用ajax post發送Javascript字符串值?任何鏈接?謝謝(我是新手) – Foobarer