简体   繁体   English

使用URLConnection时如何关闭javascript加载?

[英]How do I turn javascript loading off when using URLConnection?

I'm looking to load the version of a site within the Noscript tags so the connection has to appear like it has Javascript disabled. 我想在Noscript标签中加载一个站点的版本,所以连接必须显示它已禁用Javascript。

Thanks! 谢谢!

The UrlConnection will doesn't not need to do anything with the noscript tag, in fact it can't. UrlConnection不需要对noscript标记做任何事情,事实上它不能。 UrlConnection just gets the content, it doesn't try to parse it and do anything with JS/HTML, etc. It's just text data as far as it cares. UrlConnection只是获取内容,它不会尝试解析它并使用JS / HTML等做任何事情。它只是它关心的文本数据。

When the noscript comes into play is when you go to render the content. 当noscript发挥作用时,你去渲染内容。

Re your comment to your question - when you disable JS and go to that URL you're still getting the same content as when you requested the URL with JS on. 重新评论您的问题 - 当您禁用JS并转到该URL时,您仍然获得与使用JS请求URL时相同的内容。 If you look at the HTTP response in something like firebug you'll see it's always the same. 如果你看一下像firebug这样的HTTP响应,你会发现它总是一样的。 It's the rendering engine that is doing something different, so you need to look at where your app renders the content and see if you can disable JS there. 这是渲染引擎正在做一些不同的事情,所以你需要查看你的应用程序呈现内容的位置,看看你是否可以在那里禁用JS。

Download the page, parse it, and look for an iframe like this: 下载页面,解析它,并寻找像这样的iframe:

<iframe
src="http://api.recaptcha.net/noscript?k=6LcQ8gUAAAAAAHGMy5-aJPjhxidK2lV1KLGyJYfO"
height="300" width="500" frameborder="0"></iframe>

Load the URL specified in the src attribute to get to the noscript version. 加载src属性中指定的URL以获取noscript版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM