In html we can specify the charset for the whole document using:
<head>
<meta charset="utf-8" />
</head>
But sometimes, it is impossible to change the charset of the whole page, for example , using injection.
I would like to declare the charset for a specified element, like this
<span charset="utf-8">....</span>
but it seems it doesn't work.
Any ideas?
It is impossible to do this.
It is also difficult to design a way for this to work even theoretically. Think about it: the browser already parses your syntax using the charset. Considering implicit tag closing rules in HTML making this work would be difficult indeed.
What you can do is include an IFrame with a completely different document using a different charset.
To understand this limitation even better the meta http-equiv elements are not even part of the HTML document architecturally. Rather they are another way to specify HTTP headers if you cannot do it in HTTP server configuration.
Related
I'm looking into using Facebook's Open Graph but in certain circumstances I need to unset properties. For complicated reasons removing the meta elements might not be possible but changing it might be.
Is it considered valid for this:
<meta property="og:image" content="https://example.com/image.jpg">
To be reset by simply doing this:
<meta property="og:image" content="">
...Or is this considered invalid and bad form?
According to the specification, a URL is:
A sequence of Unicode characters that identify an Internet resource. All valid URLs that utilize the http:// or https:// protocols
An empty string is invalid.
But it won't break anything. A crawler will see the metatag, and then try to display the empty content.
I have standard html files with their own style, and use a common css file for different fonts only. I need to put the FB website thumbnail to all the files through that css.
Is it possible to add the following to the css or .js files? (as there are thousands of html files):
<meta property="og:image" content="http://websitename/image.jpg">
You'll need to add that snippet to the html itself, not the css. Meta tags go into the head of your webpage (between the <head></head> tags). There's no way to insert html into a page via a css file.
OpenGraph is some standard - even if you did put it inside your CSS - nobody would know it's there - so no, it can't be done with CSS.
If some website would process the javascript (but facebook hardly would) you could get lucky but the chances are really low so it is not reliable.
However I suggest you to write a little e.g. PHP skript that would run through all the .html / .htm files and would rewrite <head> with <head> <meta property="og:image" content="http://websitename/image.jpg">
But I suggest that instead of adding only html, it would be much better if you would add an include script that would contain further cross-files changes. So next time you would need to add something to <head> in all your files you would just add it inside your e.g. my_include.php
EDIT:
I would also recommend you to look at the facebook's developer tool that tells you exactly what it sees when it visits your site: https://developers.facebook.com/tools/debug/og/echo?q=YOURSITEURL
I'm working on a large asp.net web project that has had a number of different developers/consultants making changes to it over the last few years. I've noticed that depending on the developer, paths to images and other static content may contain the correct casing, all lower case, or something completely random. The browser appears to be making multiple requests for the same asset due to the difference in casing. For example -
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<img src="http://cdn.sstatic.net/stackoverflow/img/sprites.png" />
<img src="http://cdn.sstatic.net/stackoverflow/Img/sprites.png" />
</body>
</html>
Aside from searching for every image in the project and normalizing the casing, is there anything that can be done here? Perhaps something I can put in the page response headers to tell the browser to ignore casing, etc.
Well, the browser (it's not just Chrome that does it, any browser that doesn't is buggy) has to do this because there's no way for it to know that you happen to be using a case-insensitive mapping, so <http://cdn.sstatic.net/stackoverflow/img/sprites.png> and <http://cdn.sstatic.net/stackoverflow/Img/sprites.png> are completely different URIs.
There's a few things you can do.
First find-replace those that are:
Particularly commonly used.
Particularly heavy files.
Particularly commonly mis-spelt.
Not likely to result in you find-replacing something that ruins unrelated code.
Another thing you can do is to force canonicalisation of case in a handler that when invoked for a URI that doesn't match your case-canonicalisation rules, 301's to the form that does. This means that rather than grab 3 different 10kb images you'll grab 1 10kb image and have 2 or 3 redirects of a couple-hundred bytes. That said, below a certain file size then cost of an extra request out-weighs the saving.
Finally you can use a filter (a stream object that Response.Filter is set to, that writes to the previous value of Response.Filter) or code in the PreRender step that scans for local URIs (if you change the case of URIs on other sites you could result in 404s) and outputs them correctly.
I generate an XHTML document and set the Mime type as "application/msword" so it opens in Word.
To create a header I appear to have to reference an external file thus:
<style>
...
#page{mso-footnote-separator:url("**OUT_files/header.htm**") fs;
mso-footnote-continuation-separator:url("OUT_files/header.htm") fcs;
mso-endnote-separator:url("OUT_files/header.htm") es;
mso-endnote-continuation-separator:url("OUT_files/header.htm") ecs;}
#page Section1{
mso-header-margin:.5in;
mso-header:url("OUT_files/header.htm") h1;
} }
...
</style>
Does anyone know how to reference a div defined within the main XHTML document itself, without having to reference an external file?
Thanks
MS Word is quite locked down. I was not able to get this to work with a non-external file, but it seems to make sense. The values being "included" are repeated in the display. It's not possible to have "hidden" divs and refer to them (at least, not when I was trying), so not sure how to get this to work properly.
For me, I ended up just creating a simple Macro that would handle this for me.
If you are very lucky, a data: URL might work, maybe, in Word 2007? I haven't tried that myself, but MS introduced partial support for data: URLs in IE8.
Is there any way of pulling in a CSS stylesheet into FireFox 2 or 3 that is not a static file?
Bellow is the code we are using to pull in a stylesheet dynamically generated by a CGI script.
<link rel="stylesheet" href="/cgi-bin/Xebra?ShowIt&s=LH4X6I2l4fSYwf4pky4k&shw=795430-0&path=customer/DEMO/demo1.css" type="text/css">
/cgi-bin/Xebra?ShowIt&s=LH4X6I2l4fSYwf4pky4k&shw=795430-0&path=customer/DEMO/demo1.css
Note that the URL above that pulls in the CSS does not end with .css rather the parameters do.
Is the Content Type from the server the correct one for the file that is served up?
Content-type: text/css
why isn't this working?
Double check that the response header for the cgi script has
Content-Type: text/css
The extension doesn't matter but you should make sure the content type is "text/css".
I've done the same thing in the past - a former employer's site uses a link tag much like yours, and works fine in FF2 at least (I just checked it, though I tested it in FF when we added that link). If it's not working, I'd suspect it's something about the generated CSS file rather than the importing page. The consensus appears to be the Content-Type from the server may be wrong.
Your server procs (like the CGI) run first, don't they? Seems to me that that link tag will only pull in a file that exists already.
So what I'd do is put a server tag (my lang's ASP/ASP.Net, but you could use PHP or anything, really) in the href.
Like so:
<link rel="stylesheet" type="text/css href="<% =getStylesheetPath() %>" media="all">
Give that a shot.