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 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记