I'm sorry, but I am not very good with programming. I am trying to fix this irritating bug on my school's website through a userscript. I have tested the RegEx on several pages, at least that works. I need to make the userscript remove the parts I don't want to see. This is a snippet from the source of the website, I have marked what needs to be removed with '//'.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
//<html><head>
//<title>404 Not Found</title>
//</head><body>
//<h1>Not Found</h1>
//<p>The requested URL /get.php was not found on this server.</p>
//</body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="robots" content="index, follow" />
This is my userscript that does not work. I know it reflects my skills as a programmer, please don't hate.
var REGEX = /<HTML>(.*?)([^\n]*?\n+?)+?<\/BODY><\/HTML>/ig;
document.body.innerHTML=document.body.innerHTML.replace(REGEX, '');
This markup is obviously invalid, but the browser (at least Chrome and Firefox) will merge these two <html> sections together with its best guess. So interacting with document.body is probably not what you want.
Doing something like this will visually fix the issue:
document.querySelector('h1').remove() // remove first h1 "Not Found"
document.querySelector('p').remove() // remove first p "The requested..."
Related
I have at the start of the HTML Template:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org
/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=300, initial-scale=1.0, target-densitydpi=device-dpi">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="format-detection" content="telephone=no" /> <!-- disable auto telephone linking in iOS -->
<head>....
However, when it comes to old email clients, my HTML doesnt render at all, and is blank... I have tested this on litmus.
Is there something that I need to add or remove from above so that it also renders in the old browsers as well.
Thanks
Your meta tags should be inside the <head>.
What you have there otherwise looks fine, so it may have something to do with the rest of your document. I would recommend starting with Sean Powell's email boilerplate and bringing some of your code over.
Failing that, have you forgotten to close any elements such as tables/rows/cells?
Which email clients is it broken in?
Im aware there are other posts on character encoding however this one appears to only occur before the doctype.
My original source is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="telephone=no" name="format-detection">
<title>TITLE</title>
</head>
But it comes through in an email as (note the question marks at the start):
???<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="telephone=no" name="format-detection" />
<title>TITLE</title>
</head>
This seems strange as there are no characters or whitespace before the doctype. I don't really get 'what' can't be rendered. Also, the file was originally saved in visual studio using the following settings:
Any help much appreciated
There are actually characters before the doctype. As you have saved the file as UTF-8 with signature, it contains a BOM (byte order mark) at the beginning of the file.
Save it as UTF-8 without signature, and the characters will go away.
You don't have a *< / html > * tag ending the whole code. Try that. If it still isn't working, I suggest you use notepad++ instead of Visual Studio.
I am trying to rewrite old php mysql website in codeigniter, The site is in unicode, and text in database is stored like this
बेलायतम&.
when i pull data from database and display in html it appears like this
सरà¥à¤µà¥‹à¤šà¥à¤šà¤•à¥‹ à
It is fine in old site, I am using exactly as same header as old site in html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
I am banging my head how to correct text ?
Try this
<meta charset='utf-8'>
There should be a problem, html's codes you are using are right, just in case check if you can see proper characters on this website:
http://www.unicodeblocks.com/block/Devanagari
and make sure you are using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Please double check it - use "view page source" on your page and check, maybe you used meta tag twice with different variables?
and one more...
if you are using db, please do this:
$mysqli->query('set character set utf8');
This is my htmlcode
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
</head>
<body>
“”
</body>
</html>
This is what I see in firefox “â€
I wonder why.
To write characters outside the standard ASCII set (which is common among almost all encodings) without using HTML entities, you have to make sure that the file is actually saved using the encoding that you specify in the meta tag.
Your page is saved as UTF-8 (the default), which means that those characters will be wrong when the browser tries to decode them as Windows-1252.
You need to use the HTML entities for smart quotes: “ for the left, ” on the right.
More info here.
When I paste in the url of my page on Facebook, it doesn't pick the title etc.
I've got this in the head:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<meta property="og:title" content="Baten 2012">
<meta property="og:type" content="website" >
<meta property="og:image" content="http://www.nygeneration.se/båten/img/fb.jpg">
<meta property="og:url" content="http://www.nygeneration.se/båten/"/>
<meta property="og:description" content="Jesus. 2000 ungdomar. EN STÖRT. STOR. BÅT.">
But it doesn't work. Facebook's url debugger says that the url and title aren't declared, but as far as I know they are. What am I missing here? The page in question is here.
Interesting fact by the way is that if I serve the page from the Public folder of my Dropbox it does work.
The problem I've seen is that the sharer.php cache everything really hard so it could be a little bit hard coding as "try/trial and error". I create meta tags from code-behind/serverside and in the end of links for urls and images I add ?v=DATETIME so the result will be like; ../image.jpg?v=20120217120412,.. works like a charm!
the meta tags look good, I do not use the extra xmlns:xx i the html tag, works anyway
You should close all meta tags with />
the <html> also missing.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="https://www.facebook.com/2008/fbml">
at the top of page use
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
instead of
<!DOCTYPE html>