Hi,
Anyone pls tell me where is the issue?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<?php
$ss='<script type="text/javascript"><!--
google_ad_client = "pub-3229609591361912";
/* 728x90,created 5/2/08 */
google_ad_slot = "0355456913";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';
//echo $ss;
?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div id="container">
This is the default text
</div>
<script type='text/javascript'>
window.onload = function(){
var d = document.getElementById('container');
var def = d.childNodes[0].nodeValue;
t = 5000;
setTimeout(function(){
d.childNodes[0].nodeValue ='<?php 'echo $ss;'?>';alert('<?php 'echo $ss;'?>');
setTimeout(function(){
d.childNodes[0].nodeValue = def;
setTimeout(function(){
d.childNodes[0].nodeValue = '';
}, t);
}, t);}, t);
};
</script>
</body>
</html>
this is a php file. If you request the url in your web browser, the php will be executed and the resulting text will be output.
you can then:
-see the javascript errors generated by looking at your browsers error log
-right click > view source and see the probably invalid javascript you have created
It’s better to first manually create some javascript that works. Once you do that, then, you can worry about using php to generate it. This way you have something working to compare to.
I tried the following code and it works fine for me.But I used rawurlencode.So the $ss value is encoded.But it is not executing the code.The encoded text just appears.Pls look into it where I went wrong.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<?php
$ss='</script><script type="text/javascript"><!--
google_ad_client = "pub-3229609591361912";
/* 728x90,created 5/2/08 */
google_ad_slot = "0355456913";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript" src = "http://pagead2.googlesyndication.com/pagead/show_ads.js"></script><script>';
$ss=rawurlencode($ss);
//echo $ss;
?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div id="container">
This is the default text
</div>
<?php
echo <<<TXT
<script type='text/javascript'>
window.onload = function(){
var d = document.getElementById('container');
var def = d.childNodes[0].nodeValue;
t = 5000;
setTimeout(function()
{
d.childNodes[0].nodeValue = '$ss';
//alert('$ss');
setTimeout(function()
{
d.childNodes[0].nodeValue = def;
setTimeout(function()
{
d.childNodes[0].nodeValue = '';
},
t);
},
t);
},
t);
};
</script>
TXT;
?>
</body>
</html>
The timeout works for me. As for the rawurlencode stuff, it looks a mess. The extraneous script tags will only work inside existing script tags, not a div, and rawurlencode is for transport (HTTP requests) not the DOM. Also if you’re messing with Google’s code, it violates their Terms.