Thread: javascript in echo php
Results 1 to 3 of 3
Related
-
add code for font size under php echo code Forum: PHP Forum
Replies: 0 -
echo Javascript Forum: PHP Forum
Replies: 1 -
Javascript event inside echo statement Forum: PHP Forum
Replies: 2 -
Javascript in php echo() Forum: PHP Forum
Replies: 6 -
Is it possible to stop a javascript function w/ other javascript code? Forum: Javascript Forum
Replies: 5
-
09-22-2009, 09:04 AM #1
javascript in echo php
HI...I am not much familiar with php.I have this php code below in which I want to use the javascript code.I tried to add but it results in blank page:
CODE STARTS:--->
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'. $this->language.'" lang="'.$this->language.'" >';
echo '<head>
<link rel="shortcut icon" href="favicon.ico" >
<link rel="icon" type="image/gif" href="animated_favicon1.gif" >
<jdoc:include type="head" />
<link rel="stylesheet" href="'.$this->baseurl.'/templates/'.$this->template.'/css/template.css" type="text/css" />
<link rel="stylesheet" href="'. $this->baseurl .'/templates/'. $this->template.'/css/menu.css" type="text/css" />';
echo '<script type="text/javascript"><!--//--><![CDATA[//><!--
sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//--><!]]></script><style type="text/css">';
if(!$this->countModules('left')) : echo '#main{width:100%!important; float:left;}';
endif;
if($this->countModules('user1 + user2')==1) : echo '#user2{width:100%;}';
endif;
if(!$this->countModules('right')) : echo '#middle{width:100%;}';
endif;
echo '</style></head><body><div id="bgtop" align="center"><div class="wrapper"><div id="header"><div id="logo"><jdoc:include type="modules" name="header" style="xhtml" /><img src="'. $this->baseurl .'/templates/'. $this->template.'/images/logo.gif"></div>';
if($this->countModules('user3')) : echo '<div id="user3"><jdoc:include type="modules" name="user3" style="xhtml" /></div>';
endif;
echo '<div class="clear"></div></div>';
if($this->countModules('menu')) : echo '<div id="nav"><jdoc:include type="modules" name="menu" style="xhtml" /></div>';
endif;
echo '
<div class="clear"></div>
</div></div>
<div id="bgbottom" align="center"><div class="wrapper">
<div id="container">';
if($this->countModules('left')) : echo '<div id="left"><div class="banneritem"><jdoc:include type="modules" name="left" style="xhtml" /><div class="clr"></div>
</div></div>';
endif;
echo '<div id="main">';
if($this->countModules('user1 + user2')) : echo '<div id="user12"><div id="user1"><jdoc:include type="modules" name="user1" style="xhtml" /></div><div id="user2"><jdoc:include type="modules" name="user2" style="xhtml" /></div><div class="clear"></div></div>';
endif;
echo '<div id="br"> <div id="middle"><div id="mainbody"><jdoc:include type="component" style="xhtml" /></div>';
if($this->countModules('top')) : echo '<div id="top"><jdoc:include type="modules" name="top" style="xhtml" /></div>';
endif;
echo '</div>';
if($this->countModules('user4 + right')) : echo '<div id="right">';
if($this->countModules('user4')) : echo '<div id="user4"><jdoc:include type="modules" name="user4" style="xhtml" /></div>';
endif;
if($this->countModules('right')) : echo '<div id="rightmodule"><jdoc:include type="modules" name="right" style="xhtml" /></div>';
endif;
echo '</div>';
endif;
echo '</div></div><div class="clear"></div></div><div id="footer"><div class="bgright"><div class="bgleft">';
// <!-- Footer Links Are In The Contract Of Use. If You Dont Want Them, Then Use A DIFFERENT Template! -->
echo '<div id="getmesome" style="text-indent:-9000em;margin-top:-50px">';
echo '<jdoc:include type="modules" name="footer"/>';
echo '</div></div></div>';
</body></html>';
?>
--->CODE ENDS
And I want to add the below javascript code in the above php file.Please tell me what tags/code I need to use.
CODE STARTS:--->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-10706039-1");
pageTracker._trackPageview();
} catch(err) {}</script>
--->CODE ENDS
Thanks
leen
-
09-24-2009, 11:13 AM #2
Re: javascript in echo php
The easiest way to do what you are asking is to do the following:
1. Look for the following line:
PHP Code:echo '</div></div></div>';
PHP Code:?>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-10706039-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<?php
PHP Code:</body></html>';
PHP Code:echo '</body></html>';
-
09-25-2009, 04:29 AM #3
Re: javascript in echo php
hi...
Thanks a lot ..it worked along with certain more editings
u r awsome...
Regards
Leen
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum