doulin6088 2014-08-14 10:16
浏览 52

PHP可以在执行之前编辑javascript代码

Is it possible to edit javascript code so that before it executes on page load I can inject few code changes through PHP. I want to use PHP so that changes happen on the server before page is loaded onto client side.

For example, this is what I have:

<script>
    video38.addParm("<param name='FlashVars' value='file=abc&fullscreen=true&width=440&height=241&'>")
</script>

And this is what I want:

<script>
    video38.addParm("<param name='FlashVars' value='file=abc&fullscreen=true&width=440&height=241&oneMoreParameter=paramValue'>")
</script>

I tried this with jquery but because this is flash, once it is loaded then adding parameter doesn't do anything. That's why I thought doing it in PHP because it executes on server side.

Any help on this will be great. Thanks!

  • 写回答

2条回答 默认 最新

  • duandaishi9268 2014-08-14 10:20
    关注
            $ob = ob_start();
            //EXECUTE YOUR CODE HERE, THE PAGE AND STUFF e.g. include('./file.html');
            $pi = ob_get_contents();
            ob_end_clean();
            $js = <<<'EOD'
    video38.addParm("<param name='FlashVars' value='file=abc&fullscreen=true&width=440&height=241&oneMoreParameter=paramValue'>");
    EOD;
            $pi = preg_replace("@video38.addParm(.*?);@s", $js, $pi);
            echo $pi;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog