基本的php问题。将javascript添加到.php页面 [英] basic php question. adding javascript to .php page

查看:87
本文介绍了基本的php问题。将javascript添加到.php页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是一个php开发者,我从来没有碰过它。但我被要求将谷歌购物车跟踪代码添加到网站。当有人完成订单然后被发送到finishorder.php。当我去finishorder.php文件时它看起来像这样:

Hi i am not a php developer, ive never touched it before. but i have been asked to add a google shopping cart tracking code to a website. when someone completes an order then get sent to finishorder.php. when i go the finishorder.php file it looks like this:



include(dirname(__FILE__)."/init.php");
$GLOBALS['ISC_CLASS_ORDER'] = GetClass('ISC_ORDER');
$GLOBALS['ISC_CLASS_ORDER']->HandlePage();

对我来说看起来像服务器脚本(来自.net背景),所以我认为我不能在这里添加javascript,php如何决定获取此页面的布局?如何将javascript代码添加到此页面。

which just looks like server script to me (coming from a .net background), so i presume i cannot add the javascript here, how does php decide get the layout for this page? how can i add the javascript code to this page.

推荐答案

您可以这样做:

include(dirname(__FILE__)."/init.php");
$GLOBALS['ISC_CLASS_ORDER'] = GetClass('ISC_ORDER');
$GLOBALS['ISC_CLASS_ORDER']->HandlePage();

echo '<script type="text/javascript">YOUR JS HERE</script>';

OR

<?php
include(dirname(__FILE__)."/init.php");
$GLOBALS['ISC_CLASS_ORDER'] = GetClass('ISC_ORDER');
$GLOBALS['ISC_CLASS_ORDER']->HandlePage();
?>
<script type="text/javascript">YOUR JS HERE</script>

嗯?

但我认为HandlePage()方法将对我们的页面执行某些操作,因此我将查看此方法类ISC_ORDER-> handlePage()它的作用...然后您可以在适当的位置回显此方法...

But I think that HandlePage() method will do something with our page so I'd look inside this method Class ISC_ORDER->handlePage() what it does... You can then echo Your within this method on appropriate place...

编辑:

<?php
echo '<script type="text/javascript">//<!--
        alert("Hello to multiline JS script");
        alert("Do You get it?");
    //--></script>';
?>

这篇关于基本的php问题。将javascript添加到.php页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆