2010-02-20 15 views
1

我有我的网站与phpbb,所以你登录到phpbb,然后你将能够看到我的网站,所以我不使用正常会议,所以我不知道如何做到这一点。动作和确认 - 不同的页面,我如何传递文本?

我的网站是在index.php的设计,然后我有一个框架内的insert.php。现在在我的index.php,我想收到一条消息,并在insert.php,我想发送一条消息。

在insert.php中的数据库中插入某些内容后,我想正确理解我,我想显示一条消息,如StackOverflow(在index.php中),并说“您已收到+分数”。现在我不知道如何“传递”信息。

我的意思是,从insert.php到index.php。

然后我一直在考虑每2秒进行一次自动刷新,以检查是否有任何新消息要显示。

谢谢 Azzyh

而且忘了提: 我的index.php是/ 我insert.php是/videos/insert.php 在/videos/show.php,键入评论,然后, Insert.php将评论插入到数据库中, 我在show.php中做了一个脚本,它将字符串发送到insert.php,然后insert.php插入,然后它将输出的结果以i有在show.php(如“成功插入!”)。所以我应该真的在insert.php或脚本中做些什么,如果成功插入? 这里是我的脚本中,我提到:

var nocache = 0; 
function insert() { 
// Optional: Show a waiting message in the layer with ID login_response 
document.getElementById('insert_response').innerHTML = "To Sek .. " 
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding. 
var fID= encodeURI(document.getElementById('fID').value); 
var kommentar= encodeURI(document.getElementById('kommentar').value); 
// Set te random number to add to URL request 
nocache = Math.random(); 
// Pass the login variables like URL variable 
http.open('get', 'insert.php?fID='+fID+'&kommentar=' +kommentar+'&nocache = '+nocache); 
http.onreadystatechange = insertReply; 
http.send(null); 
} 
function insertReply() { 
if(http.readyState == 4){ 
var response = http.responseText; 
document.getElementById('insert_response').innerHTML = ''+response; 
} 
} 

回答

1

在父页面(的index.php)定义,你可以从孩子页面调用javascript函数:

function someFunction(msg) { 
    alert(msg); 
} 

,并在子页( insert.php),你可以调用这个函数:

if (window.parent) { 
    window.parent.someFunction('hello world'); 
} 

注意的是,由于cross domain policies这将工作只有两页是在同一个域。

+0

你好Darin。请阅读我更新的答案,我有这个问题,因为正如我在更新的答案中所说的那样,我正在使用脚本来插入注释和输出响应(因此您将所有内容都放在一个页面中).. – Karem 2010-02-20 12:31:07

相关问题