即时镜像网站以供移动使用
我想创建一个网站的移动版本。我没有对源网站的写入权限。源网站的 HTML 格式良好,并且大多数针对移动设备查看的调整都可以通过 CSS 覆盖来实现。
我很快就发现了用于移动浏览网站的 Google 工具;像这样的某种即时镜像对我来说似乎是最佳的(可能通过 PHP 或 AJAX/JS),但我找不到任何流行的方法或包来做到这一点。
我现在将继续尝试使用 jQuery 动态加载网站;我想在应用一些 CSS 和 JS 格式化规则之前,我必须用 AJAX 调用替换链接并使图像引用绝对化。
如果有更好的方法来做到这一点,我将不胜感激!
I would like to create a mobile version of a website. I do not have write access to the source website. The source website is well formatted in HTML and most adaptations for mobile viewing should be possible with CSS overrides.
I quickly came across the Google tool for mobile viewing of web sites; some sort of on-the-fly mirroring like that seems optimal to me (maybe via PHP or AJAX/JS), but I couldn't find any popular methods or packages to do this.
I will go ahead for now and try to load the site dynamically using jQuery; I suppose I will have to replace the links with AJAX calls and make the image references absolute before applying some CSS and JS formatting rules.
If there is a better way to do this however, I would much appreciate it!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您无法使用 jQuery 加载其他网页,因为大多数浏览器中的设置都会阻止打开具有不同域名的网站(以阻止攻击,这是使用您尝试执行的操作的另一种方式)< strong>[编辑:这是关于 XSS 安全性]
至少我不相信如果不更改此设置就可以在 Javascript 中完成。然而服务器端应用程序不应该有这样的问题。
如果您决定在 asp 中执行此操作,那么我会推荐 HTMLAglityPack。它是一个非常好的 html 解析器,允许您像 xml dom 一样与 HTML 交互,从而更容易更改链接和引用。另外.net的System.Uri类将使您能够找到链接/图像/javascript/等的绝对位置,
我绝不是说这是最好的方法,甚至是一种可以实现的方法。为您提供最好的工作;这只是我所知道的一种
编辑:
尝试使用其中之一来解析 HTML。它肯定比乱搞不合适的正则表达式要容易得多
XML 解析器
HTML 解析器
I don't think you'll be able to load other webpages with jQuery due to a setting in most browsers that prevents opening websites with different domain names (to stop attacks that are another way to use what you're trying to do) [EDIT: This is talking about XSS security]
Least I don't believe without changing this setting it can be done in Javascript. However a server side application should have no such problem.
If you decide to do this in asp then I would recommend the HTMLAglityPack. Its a very nice html parser that allows you to interact with the HTML as if it was an xml dom, making changing links and references easier. Also .net's System.Uri class will enable you to find the absolute location of a link/image/javascript/etc
I'm by no means saying this is the best way, or even a way that will work best for you; this is just a way that I know of
Edit:
Try to use one of these for parsing your HTML. Its bound to be ALOT easier than messing about with ill-suited regular expressions
XML Parsers
HTML Parsers