Подгрузка удаленного скрипта средствами JS
Всем привет!
Задача такая. Нужно подгрузить удаленный JS файл средствами JS. Сейчас схема работает так: Подгружаем скрипт: <script type="text/javascript" src="http://site.ru/1.php"></script> который выглядт так: <?php $array=file("http://site2.ru/script.js"); foreach($array as $string) echo $string; ?> Этот скрипт стягивает JS скрипт с другого сайта. script.js выглядит так: function get(r, key) { window.open('http://site3.ru/'+key); } На сайте 1 (site.ru) ссылка подгружается соедующим образом: <div class="downl"> <a href="" class="kach" id="splLink"></a> <div id="splCont" style="display:none; margin-top: 20px;"> <p align="justify" id="timtext">Ссылка на скачивание презентации появится через:</p> <div id="timer" align="center"> <script type="text/javascript"> $(document).ready(function () { $('#splLink').click(function () { $(this).parent().children('div#splCont').show("normal"); var seconds = 20; $("#splCont>div").text(seconds); var timer = setInterval(function () { seconds--; if (seconds != 0) { $("#splCont>div").text(seconds); } else { $("#splCont>div").html('<a href="javascript:get(document.referrer, \'название файла\');" id="kiloer">Скачать</a>'); clearInterval(timer); } }, 1000); $('#splLink').unbind("click"); $('#splLink').click(function () { return false; }); return false; }); }); </script> </div> </div> </div> Т.е. тут идет еще таймер, но на него внимания не обращаем. Нужно, чтобы все работало точно также, только чтобы заместо PHP скрипта был JS скрипт. Как такое можно сделать? |
<script type="text/javascript" src="http://site2.ru/script.js"></script>
$array=file("http://site2.ru/script.js"); foreach($array as $string) echo $string это бессмыслица, уж тогда echo(file_get_contents($url)); |
Часовой пояс GMT +3, время: 14:56. |