Search code examples
javascriptphpjqueryloadbookmarklet

Load scripts with bookmarklet or some jQuery function


I have a some code here and I with this code render external page (similar to iframe) but I got a source code. But when I start my code all is good but one window is showing there and I can't to close his to see contents. Here is the code:

<?php

$url = 'http://www.kupime.com/';

$data = file_get_contents($url);

$data = '<head><base href='.$url.' target="_blank" /></head>'.$data;

echo $data;

?>

and this generate a good HTML page but to close window I need also to get all scripts with this bookmarklet :

javascript: (function(){
    s = document.getElementsByTagName('SCRIPT');
    tx = '';
    sr = [];
    for (i = 0; i < s.length; i++) {
        with (s.item(i)) {
            t = text;
            if (t) {
                tx += t;
            }
            else {
                sr.push(src)
            };
                    }
    };
    with (window.open()) {
        document.write('<textarea%20id="t">' + (sr.join("\n")) + "\n\n-----\n\n" + tx + '</textarea><script%20src="http://jsbeautifier.org/beautify.js"></script><script>with(document.getElementById("t")){value=js_beautify(value);with(style){width="99%";height="99%";borderStyle="none";}};</script>');
        document.close();
    }
})();

but how to implement this in my code above... ??? please HELP!

here is the demo of first (only php code) http://www.pluspon.com/get1.php


Solution

  • Try to get all content with (and script offcource) instead your solution with;

    $site = fopen('http://www.google.com', 'r');
    $store = 'store.php';
    $stream__ = stream_get_contents($site, -1);
    
    file_put_contents($store, $stream__, LOCK_EX);
    fclose($site);
    $check = file_get_contents($store);
    
    # var_dump($check); print_r($check); var_export($check); 
    # or simple... 
    
    echo $check;