1

Why are jQuery source view pages not allowed as hyper-links on Stack Overflow?

Is it for browser compatibility concerns? Or is it perhaps for the same reason Stack Overflow disallows links to jsFiddle without code in the post?

Enter image description here

1 Answer 1

4

It has nothing to do with jQuery source links. This:

http://view-source:http://code.jquery.com/ui/1.11.1/jquery-ui.js

is not a valid URL, which is what the script is actually complaining about.

To actually view the source, you would use solely the view-source browser scheme, like so:

view-source:code.jquery.com/ui/1.11.1/jquery-ui.js

That URI scheme is not allowed on the network and will not even render as a link when used (only plain text). There's really no reason to allow it, as there's rarely ever a circumstance wherein it's actually useful to reference a live file somewhere on the web and point to a line number. In fact, I'm not entirely convinced it's even useful here. It'd probably be far better off to just extract a small section out of that file which contains the line you're referencing.

4
  • I'm pretty sure the correct view-source: URI would be view-source:http://code.jquery.com/ui/1.11.1/jquery-ui.js. Yes, there's (effectively) a double scheme, because to view the source, the browser needs to know the scheme (http) of the original URI. Oct 12, 2014 at 12:25
  • @Ilmari True, but most browsers nowadays chop off the http. You would have to includd it if it were https.
    – animuson StaffMod
    Oct 12, 2014 at 13:24
  • Is there any way to share page source links? Obviously [text](view-source:{url}) doesn't work. I tried to share the page source links many times while answering web-scraping questions. Apr 17, 2018 at 4:51
  • 1
    @Keyur "That URI scheme is not allowed on the network". So no.
    – animuson StaffMod
    Apr 17, 2018 at 4:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .