即时镜像网站以供移动使用

发布于 2024-10-10 20:30:37 字数 354 浏览 0 评论 0原文

我想创建一个网站的移动版本。我没有对源网站的写入权限。源网站的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心安伴我暖 2024-10-17 20:30:37

我认为您无法使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文