使用小书签或某些 jQuery 函数加载脚本
我这里有一些代码,我用这个代码渲染外部页面(类似于 iframe),但我得到了源代码。但是当我开始我的代码时,一切都很好,但那里显示一个窗口,我无法关闭它来查看内容。这是代码:
<?php
$url = 'http://www.kupime.com/';
$data = file_get_contents($url);
$data = '<head><base href='.$url.' target="_blank" /></head>'.$data;
echo $data;
?>
这会生成一个很好的 HTML 页面,但要关闭窗口,我还需要获取带有此书签的所有脚本:
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();
}
})();
但如何在上面的代码中实现这一点...???请帮忙!
这是第一个演示(仅 php 代码) http://www.pluspon.com/get1.php< /a>
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用(以及非源脚本)获取所有内容,而不是使用以下解决方案;
Try to get all content with (and script offcource) instead your solution with;