...

View Full Version : Variable value with page Title?



toplisek
07-17-2012, 03:27 PM
I have Title like:
Title1 | Title2 | Title2 | Mydomain

Javascript code like:



<a href="#" class="button1" style="width:200px;" onclick="Printmypage('printmypage','title1','popup',true)"><i class="icon"></i>Print page</a></div><div id="printmypage">



how to change automatic this variable title1
('printmypage','title1','popup',true)

into existing page Title with support of Javascript and/or PHP?

sunfighter
07-17-2012, 05:45 PM
Really not completely sure what you want. Maybe this is it for both things I think you want:


<?php
$title = 'title1'; // Or anything you want here
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Big Title</title>
<script type="text/javascript">
function Printmypage(a,b,c,d)
{
document.title = b;
}
</script>
</head>
<body>
<a href="#" class="button1" style="width:200px;" onclick="Printmypage('printmypage','<?php echo $title; ?>','popup',true)">
<i class="icon"></i>Print page
</a>
<div id="printmypage"></div>
</body>
</html>

DrDOS
07-17-2012, 06:24 PM
The javascript inside your Printmypage function has to read:

document.title = title1;

toplisek
07-17-2012, 07:24 PM
The javascript inside your Printmypage function has to read:

document.title = title1;
How to put PHP inside this title1 to read from javascript as this language is client side.

Old Pedant
07-17-2012, 07:51 PM
document.title = "<?php echo somePHPvariableOrExpression; ?>";

Old Pedant
07-17-2012, 07:52 PM
But if you are doing this from PHP, why not just do it *IN* the title?


<head>
<title><?php echo whateverPHPstuffYouWant; ?></title>
...
</head>

???



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum