简体   繁体   中英

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.

Thanks!

The UrlConnection will doesn't not need to do anything with the noscript tag, in fact it can't. 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.

When the noscript comes into play is when you go to render the content.

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. If you look at the HTTP response in something like firebug you'll see it's always the same. 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.

Download the page, parse it, and look for an iframe like this:

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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