This question already has answers here:
URI starting with two slashes ... how do they behave?
(4 answers)
Closed 9 years ago.
More and more, began to notice that the links in the source code on Web sites begin with two slashes. For example:
Image
Why do it?
It's a protocol-relative URL (typically HTTP or HTTPS). So if I'm on http://example.org and I link (or include an image, script, etc.) to //example.com/1.png, it goes to http://example.com/1.png. If I'm on https://example.org, it goes to https://example.com/1.png.
This lets you easily avoid mixed content security errors.
Related
This question already has answers here:
Two forward slashes in a url/src/href attribute [duplicate]
(2 answers)
Closed 6 years ago.
On several pages I saw in the last months following syntax for a address
...
What does this way of an url stay for? Is it a kind of wildcard for the protocol you have called this site?
It means, that the link reference uses the same protocol (http: or https:) like the current page. If you call the page with http: the link goes to http: as well, if you call the page with https: the link has https too.
This is most useful not only for links but for images, javascript and other external resources. It prevents problems with mixed (encrypted/unencrypted) content which provokes warnings in most browsers.
This question already has answers here:
String attribute values in multiple lines, HTML
(6 answers)
Adding a linebreak in some attribute string(like src or href ) in HTML / XML source
(1 answer)
Closed 3 years ago.
I have an HTML element that looks something like,
<element src="http://lsdjflksjdfkjewiojeriowjekwjekfljsdkfjisdjrsekjfijsiejisjojfsjlfejeileldjfsleisldkjfsiejljefijeljslefifjfsleif">
</element>
See how long that is?
I want to break up the src link into multiple lines.
In Python you would just use \ to break a long string into multiple lines. In JavaScript, you just use + "rest of string" to break it into multiple lines. What is the case for HTML? The browser wants to interpret my attempt as white space...
So when I did:
<element
src="http://lsdjflksjdfkjewiojeriowjekwjekfljsdkf
jisdjrsekjfijsiejisjojfsjlfejeileldjfsleisldkjfsiejljefi
jeljslefifjfsleif">
</element>
It inserted a bunch of %20 where the line breaks were. What else should I try?
On a similar post on Stack Overflow that addresses this issue, it suggests using JavaScript to split the lines up, which seems like overkill, and the answer that suggested splitting after '/'s in the URL seems not to work unless you cram the entire element on the left side of the page which would cause horrible formatting issues... Otherwise, it still put spaces in the link.
Google URL Shortener has been retired and has transitioned to Firebase Dynamic Links.
But in general, using a link shortener for external resources is a pretty terrible idea. There will inevitably be some overhead in using an external link shortener, you'll be at their mercy in the event of an outage or EOL, and there may be the possibility of redirect/poison attacks as well.
This question already has answers here:
COMPLETE list of HTML tag attributes which have a URL value?
(2 answers)
Closed 7 years ago.
Obviously a href and img src. Are there any others? How would you search for this?
One of them is certainly srcset on the picture element, well its contains a URL but is maybe one.
Not sure how to properly search for one, maybe browsers have implemented some logic like that?
Mh, at least servo has implemented a generic get_url_attribute function which tries to converts any attribute to a URL https://github.com/servo/servo/blob/master/components/script/dom/element.rs#L997 sorry no help here
This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
Can I change all my links to just //?
Network-Path Reference URI / Scheme relative URLs
Iv seen some websites using something like this:
background:url(//cdn.domain.com/images/bg-normal.png)
Notice the "//", which the browser automatically translates to "https://" if the page if using HTTPS, and translates to "http://" if the page if using HTTP.
Is it only the modern browsers who supports this notation?
Is it recommended to use this notation, or should I hardcode https:// or http:// in the CSS file depending on HTTPS or HTTP.
According to Paul Irish's blog post, it works in IE as well.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do I use Access-Control-Allow-Origin? Does it just go in between the html head tags?
I'm trying to allow cross domain requests, but I don't know where to put Access-Control-Allow-Origin. Does it go in the html request file or index.html? I put this code in my html request file, don't laugh at me if this is way off.
<head>
Access-Control-Allow-Origin: *
</head>
PHP Example - https://developer.mozilla.org/en-US/docs/Web/HTTP/Server-Side_Access_Control Server-Side Access Control (CORS)
Access-Control-Allow-Origin can't go inside the head tags, it is an html header so it belongs in php script.