我有一個從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