Using a simple example lets say there is this function in an external script: Code: function showmessage(arg){ alert(arg); } If we have different scripts eg page1.php, page2.php, page3.php etc If each one of those scripts calls the function showmessage using different arguments eg page1.php calls it like this : Code: <script language=\"JavaScript\" type=\"text/javascript\"> showmessage("page1"); </script> The above code would have to be embedded into the PHP file. My question is how can we go about doing that unobtrusively? Ie by not putting the code into the PHP files how can a different argument be passed to that function depending on what page is loaded?
Using window.location inside your javascript page will give you the current url. All you would have to do is use some if statments to see what page your on and run your code based on what page the user is on. I think that's what you're asking.