1

This URL seems to bring to an empty HTML but looking at its source (CTRL+U) there's some style in it.

However, the body tag is empty and I would need a way to test it given that the only thing I have is the source representation as text (see below).

I've been reading an answer which might be of help but so far I could not find a proper way to apply it.

Any hint would be very much appreciated.

"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html xmlns:esri_wms=\"http://www.esri.com/wms\" xmlns=\"http://www.esri.com/wms\">\r\n<head>\r\n<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"></meta>\r\n<style type=\"text/css\">\r\n\t\t\t\t\ttable, th, td {\r\n\t\t\t\t\t\tborder:1px solid #e5e5e5;\r\n\t\t\t\t\t\tborder-collapse:collapse;\r\n\t\t\t\t\t\tfont-family: arial;\t\t\t\t\t\r\n\t\t\t\t\t\tfont-size: 80%;\t\t\t\t\t\t\r\n\t\t\t\t\t\tcolor: #333333\r\n\t\t\t\t\t} \t\t\t\t\t\r\n\t\t\t\t\tth, td {\r\n\t\t\t\t\t\tvalign: top;\r\n\t\t\t\t\t\ttext-align: center;\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t\tth {\r\n\t\t\t\t\t\tbackground-color: #aed7ff\r\n\t\t\t\t\t}\r\n\t\t\t\t</style>\r\n</head>\r\n<body></body>\r\n</html>\r\n"
Jack Bashford
  • 43,180
  • 11
  • 50
  • 79
umbe1987
  • 2,894
  • 6
  • 35
  • 63

1 Answers1

1

What you can do is use the innerHTML property of all HTML tags:

var text = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html xmlns:esri_wms=\"http://www.esri.com/wms\" xmlns=\"http://www.esri.com/wms\">\r\n<head>\r\n<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"></meta>\r\n<style type=\"text/css\">\r\n\t\t\t\t\ttable, th, td {\r\n\t\t\t\t\t\tborder:1px solid #e5e5e5;\r\n\t\t\t\t\t\tborder-collapse:collapse;\r\n\t\t\t\t\t\tfont-family: arial;\t\t\t\t\t\r\n\t\t\t\t\t\tfont-size: 80%;\t\t\t\t\t\t\r\n\t\t\t\t\t\tcolor: #333333\r\n\t\t\t\t\t} \t\t\t\t\t\r\n\t\t\t\t\tth, td {\r\n\t\t\t\t\t\tvalign: top;\r\n\t\t\t\t\t\ttext-align: center;\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t\tth {\r\n\t\t\t\t\t\tbackground-color: #aed7ff\r\n\t\t\t\t\t}\r\n\t\t\t\t</style>\r\n</head>\r\n<body></body>\r\n</html>\r\n";
text.slice(1, -1);
var body = document.body;
body.replace(/ /g, "")

if (body == "") {
    console.log("Empty page"!);
}
Jack Bashford
  • 43,180
  • 11
  • 50
  • 79