我有一个从3个不同页面调用的函数。在每个页面中,我将一个attr添加到一个div。如何获取从中调用脚本的页面名称
例如:
<div id="posts" page="home"></div>
<div id="posts" page="feed"></div>
<div id="posts" page="search"></div>
在Java脚本我再拿到页的值,然后我把它传递给中,我有一个if
,elseif
和else
statemants PHP文件。
为了更安全起见,我认为如果在PHP文件中加载AJAX以获取从中调用脚本的url,因为使用google调试工具可以更改attr。
<?php
if($page =='home' && $sourceUrl == 'the home url')
{
// do this
}
elseif($page =='feed' && $sourceUrl == 'the feed url')
{
// do this
}
elseif($page =='search' && $sourceUrl == 'the search url')
{
// do this
}
else
{
exit();
}
?>
你的问题不是很清楚。你能画一幅你想要做的图像吗? – hakre 2012-04-13 13:17:41