Hi!
I've just come to ask as I am making a website.. and well, I use PHP to get the pages title. Example:
Code:
include('../../includes/core.php');
define("PAGENAME", "Random Area");
$page_name = SITESHORT . SEP . PAGENAME;
(Ignore the SITESHORT and SEP, they are already predefined variables set in core.php)
What I am trying to do, is when the menu item is clicked, the page loads in the div, and the name of the title changes to the page which is in the PHP file which is loaded into the div. (That is probably the weirdest way of putting it)
Example:
Code:
<head>
<script type="text/javascript">
function setNewTitle( name ) {
document.title = name;
}
function setPageTitle() {
var $title = "<?php echo $page_name; ?>";
setNewTitle($title);
}
</script>
</head>
<body onload="javascript:setPageTitle();">
</body>
As you can see in the above example, i'm trying to get the PHP variable '$page_name' to be put into the var I created in the javascript (maybe i'm setting the var wrong..? not very good with javascript)
Sum:
- Make PHP variables
- Javascript function tries to execute php variable
- Fails
Anybody out there who could help me?
Thanks in advance,
iBenson
|