如何使用Ajax预览网址? [英] How do I preview a url using ajax?

查看:82
本文介绍了如何使用Ajax预览网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Ajax预览网址?我已经看到了使用搜索引擎插件完成的操作,并且想学习如何执行此操作.具体来说,我希望能够将鼠标悬停在链接上,并使用ajax来查看网页的预览.

How do I preview a url using ajax? I have seen this done with search engine plug ins and would like to learn how to do this. Specifically, I would like to be able to mouse over a link and see the preview of the webpage using ajax.

推荐答案

简单解决方案,解决方案和 use-a-library解决方案.

There's the easy solution, the hard solution, and the use-a-library solution.

使用图书馆:除非您有充分的理由,否则我总是选择使用图书馆解决方案.一个可能的网站将硬性解决方案"包装为您提供服务: http://thumbnails.iwebtool.com/demo/

use-a-library : I prefer always doing the use-a-library solution unless you have a darn good reason otherwise. One possible site which wraps the "hard solution" as a service for you: http://thumbnails.iwebtool.com/demo/

简单:简单的解决方案是将目标网页作为缩小的AJAXy窗口加载.您可以使用许多Lightbox类插件来完成此任务,尤其是那些允许您为Lightbox窗口定位任意HTTP内容的插件. GreyBox 是我以前使用过的那些的最爱. Lightbox Gone Wild 也很好.

easy: The easy solution is to just load the target webpage as a downscaled AJAXy window. You can use many of the Lightbox-class plugins for this task, particularly the ones which allow you to target arbitrary HTTP content for the Lightbox window. GreyBox is my favorite of those which I have used before. Lightbox Gone Wild is also nice.

困难:然后有一个困难的解决方案:您需要呈现网页服务器端,将呈现内容缓存为图片,然后使用Lightbox风格的Javascript(紧随其他要求之后).您如何执行此操作超出了此框的范围.你为什么要这样呢?预览可以为客户端更快地生成MUCH,并且可以将客户端的会话与目标网站中可能破坏它的事物密封在一起-行为不当可能会导致Java和/或恶意软件在您打开它们(甚至在AJAXy中)时造成真正不好的事情"窗口内的窗口.

hard: Then there is the hard solution: you need to render the web page server side, cache the rendering as an image, and then serve up that image using Lightbox-esque Javascript (which is trivial next to the other requirements). How you would go about doing this is outside the scope of this box. Why would you do it this way? The preview generates MUCH faster for the client, and it hermetically seals the client's session away from things which might bust it in the target website -- poorly behaving Javascript and/or malware can cause Really Bad Things when you open them, even in an AJAXy window-within-a-window.

这篇关于如何使用Ajax预览网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆