【发布时间】:2020-02-18 16:30:58
【问题描述】:
我正在开发一个扮演搜索引擎角色的 JAVA Web 应用程序。它的后端是用 AngularJS 开发的。我有一个小的 PHP 代码,它试图通过 iframe 将输入文本中的数据发送到 JAVA Web 应用程序。数据存储在 localStorage 中。
下面是 PHP 代码:
index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script type="text/javascript">
function redirect(){
var toSearch = document.getElementById('wordToSearch').innerHTML;
console.log("toSearch : ", toSearch);
localStorage.setItem('wordToSearch', 'bdd');
window.location.href = "http://localhost:8050/searchEngine/#/search";
}
</script>
<form action="http://localhost:8050/searchEngine/#/search">
<input type="text" name="word" id="wordToSearch">
<input type="submit" value="Search" onclick="redirect()">
</form>
</body>
</html>
确切地说,我正在尝试检索存储在 localStorage 中的“wordToSearch”项值
下面是我将 iFrame 添加到我的应用程序的代码:
<iframe src='http://localhost:8040/test/index.php'></iframe>
这是我在开发者工具中得到的结果:
谁能帮帮我?
【问题讨论】:
-
放弃本地存储,尝试另一种方法
标签: javascript php local-storage