如果启用了fopen_wrappers,则可以使用file_get_contents()来检索页面,然后在将其作为输出回显之前将JavaScript插入到内容中.
$content = file_get_contents('http://example.com/page.html');
if( $content !== FALSE ) {
// add your JS into $content
echo $content;
}
Run Code Online (Sandbox Code Playgroud)
这当然不会影响原始页面.