有没有办法将外部php文件中的javascript插入主页?

时间:2021-11-05 09:50:54

I have a simple question, with maybe a difficult solution. I hope someone can help me out.

我有一个简单的问题,可能是一个困难的解决方案。我希望有人可以帮助我。

The code is a postback file, which means that the file will execute when an action is completed on another website. This is the code that I can edit:

代码是一个回发文件,这意味着该文件将在另一个网站上完成操作时执行。这是我可以编辑的代码:

$sql = mysql_query("UPDATE thescore SET score=score+".$_GET['new'] ." WHERE user_id =' " . $_GET['uid']. " ' "); 
mysql_query("INSERT INTO postbacks (page,ip,user_id) VALUES ('".$_SERVER["REQUEST_URI"]."','".$_SERVER['REMOTE_ADDR']."','".$_GET['uid']."')");

I want to add a simple alert javascript action on the main website, when the file is actived by the other site.

我希望在主网站上添加一个简单的警报javascript操作,当该文件被其他站点激活时。

I hope you can help me! Kind regards,

我希望你能帮帮我!亲切的问候,

Maarten

2 个解决方案

#1


0  

If I understand correctly, you could add the following to the file to create the alert after the query;

如果我理解正确,您可以将以下内容添加到文件中以在查询后创建警报;

echo "<script language='javascript'>\n";
echo "  alert('Some message!');";
echo "</script>\n";

#2


0  

I'm not sure of the details concerning how the file is called by the other website, but if it is something like ajax or curl, as examples, then your script won't be able to display an alert or message like you want. The other website would need to have code to accept a response and then display the alert with whatever text was sent back. In most cases like this, the other site needs to be where the alert resides--though I suppose the site could be coded to execute whatever was passed back to it, but I wouldn't recommend that (security).

我不确定有关文件如何被其他网站调用的详细信息,但如果它是像ajax或curl这样的示例,则您的脚本将无法显示您想要的警报或消息。另一个网站需要有代码来接受响应,然后显示发回的任何文本的警报。在大多数情况下,这样的另一个站点需要在警报所在的位置 - 尽管我认为该站点可以被编码为执行传回给它的任何内容,但我不建议(安全性)。

#1


0  

If I understand correctly, you could add the following to the file to create the alert after the query;

如果我理解正确,您可以将以下内容添加到文件中以在查询后创建警报;

echo "<script language='javascript'>\n";
echo "  alert('Some message!');";
echo "</script>\n";

#2


0  

I'm not sure of the details concerning how the file is called by the other website, but if it is something like ajax or curl, as examples, then your script won't be able to display an alert or message like you want. The other website would need to have code to accept a response and then display the alert with whatever text was sent back. In most cases like this, the other site needs to be where the alert resides--though I suppose the site could be coded to execute whatever was passed back to it, but I wouldn't recommend that (security).

我不确定有关文件如何被其他网站调用的详细信息,但如果它是像ajax或curl这样的示例,则您的脚本将无法显示您想要的警报或消息。另一个网站需要有代码来接受响应,然后显示发回的任何文本的警报。在大多数情况下,这样的另一个站点需要在警报所在的位置 - 尽管我认为该站点可以被编码为执行传回给它的任何内容,但我不建议(安全性)。