I have a site: http://www.quass.com/erase.php
Position of the flash widget is fine in Firefox but not in IE8
What's the reason? How to fix it?
You don't define DOCTYPE so the page is rendered in quirks mode. So you need to use a proper DOCTYPE. Here you can find what is DOCTYPE and what are the options you have. You must add it in the top of your html document. If you want to use html5 the DOCTYPE is still needed, so you have to use <!DOCTYPE HTML>. Then, whatever is your DOCTYPE choice, you can validate your web page with the w3 validator.
As answered by reiso up here, you have a malformed HTML problem. And while Firefox doesn't bother that much, IE8 is a bit pricky in this.
Check your source, close all <div>s tags before starting another <div>, if you make the html well-written and standard-compliant I'm 100% sure everything will work as you wish :)
Once I had the very same problem, and guess what? it was just a <div> tag not closed that caused IE to mess around with everything.
Your code is malformed. Most specifically you are missing a doctype declaration. <!doctype html> is a decent choice for starters — there should be absolutely no characters before it in your source.
Related
I have been attempting to use SimpleXML to parse XHTML which has been captured through output buffering. To get there I used a DOM object as per some excellent suggestions given in another question.
The simpleXML object is fired off to other classes that makes use of it to inspect and/or make changes to the page (but currently ignores it so I can get this working) and then the $xml->asXML() is then output once the manipulation is done with. It’s not simple but it is a reasonably elegant solution to working with some legacy code that I would like to replace sometime.
So far so good but the output now has odd characters that look for all the world like the result of a text encoding issue.
$doc = new DOMDocument();
$doc->loadHTML($this->PAGE); // <-- in goes nicely behaved XHTML
$doc->encoding = 'utf-8'; // This did not seem to help
$xmlObject = simplexml_import_dom($doc,$customClass);
//[...stuff...]
$this->PAGE = $xmlObject->asXML(); // -->outcomes XHTML with cruft
//[...logging and so forth...]
echo $this->PAGE;
According to the meta tag the HTML is assuming iso-8859-1
I’m seeing plenty of  if that is meaningful to anyone?
I tried to use the DOM Doc to convert to utf-8 which I guess was happening anyway because it did not make any difference. Not to mention the meta data in the xHTML is now wrong.
Is there a way of detecting the encoding in use up to that point switching and then switching back perhaps by tokenizing trouble characters or somesuch? Failing that is there another approach that would minimise the resultant mess?
I need to get this right as when finished it will be shared with a bunch of different people (in theory this could be a really big number) with different setups that I am worried about breaking.
UPDATE: Nuts! It seems that the received wisdom is that simpleXML will only deal with utf-8 so as a slight change to the question how can I html-encode anything that would suffer from the change (for the many different languages used) without also encoding the xHTML structure? Or have I hit a dead end?
I'm using XHTML Transitional doctype for displaying content in a browser. But, the content is displayed it is passed through a XML Parser (DOMDocument) for giving final touches before outputting to the browser.
I use a custom designed CMS for my website, that allows me to make changes to the site. I have a module that allows me to display HTML scripts on my website in a way similar to WordPress widgets.
The problem i am facing right now is that I need to make sure any code provided through this module should be in a valid XHTML format or else the module will need to convert the code to valid XHTML. Currently if a portion of the input code is not XHTML compliant then my XML parser breaks and throws warnings.
What I am looking for is a solution that encodes the entities present in the URLs and text portions of the input provided via TextArea control. For example the following string will break the parser giving entity reference error:
<script type="text/javascript" src="http://www.abcxyz.com/foo?bar=1&sumthing"></script>
Also the following line would cause same error:
<a href="http://www.somesite.com">Books & Cool stuff<a/>
P.S. If i use htmlentities or htmlspecialchars, they also convert the angle brackets of tags, which is not required. I just need the urls and text portions of the string to be escaped/encoded.
Any help would be greatly appreciated.
Thanks and regards,
Waqar Mushtaq
What you'd need to do is generate valid XHTML in the first place. All your attributes much be htmlentitied.
<script type="text/javascript" src="http://www.abcxyz.com/foo?bar=1&sumthing"></script>
should be
<script type="text/javascript" src="http://www.abcxyz.com/foo?bar=1&sumthing"></script>
and
Books & Cool stuff
should be
Books & Cool stuff
It's not easy to always generate valid XHTML. If at all possible I would recommend you find some other way of doing the post processing.
As already suggested in a quick comment, you can solve the problem with the PHP tidy extensionDocs quite comfortable.
To convert a HTML fragment - even a good tag soup - into something DomDocument or SimpleXML can deal with, you can use something like the following:
$config = array(
'output-xhtml' => 1,
'show-body-only' => 1
);
$fragment = tidy_repair_string($html, $config);
$xhtml = sprintf("<body>%s</body>", $fragment);
Example: Format tag soup html as valid xhtml with tidy_repair_stringDocs.
Tidy has many options, these two used are needed for fragments and XHTML compatibility.
The only problem left now is that this XHTML fragment can contain entities that DomDocument or SimpleXML do not understand, for example . This and others are undefined in XML.
As far as DomDocument is concerned (you wrote you use it), it supports loading html instead of xml as well which deals with those entities:
$dom = new DomDocument;
$dom->loadHTML($xhtml);
Example: Loading HTML with DomDocument
HTML Tidy is a computer program and a library whose purpose is to fix invalid HTML and to improve the layout and indent style of the resulting markup.
http://tidy.sourceforge.net/
Examples of bad HTML it is able to fix:
Missing or mismatched end tags, mixed up tags
Adding missing items (some tags, quotes, ...)
Reporting proprietary HTML extensions
Change layout of markup to predefined style
Transform characters from some encodings into HTML entities
I am making use of the following HTML tags and when I pass it through tidy and view the HTML output those tags have been removed. I have had a look at the list of config options but I can't find one that prevents this from happening.
Tidy removes: unsubscribe and webversion.
How can I get it to keep HTML tags like these?
PHP Tidy is aimed at correcting HTML and those tags aren't valid. Through correct configuration of php tidy you might be able to add them.
If I guessd correctly those should be blocklevel elements read how to add them here or see all of the other options.
Those aren't valid HTML tags, so Tidy will remove them. You might have to massage the text before/after to 'hide' the tags, by changing them to [unsubscribe] and [webversion], possibly, then change back to the <> versions afterwards. Another option would be to process the file as XML, which allows arbitrary tags of that sort. However, you'd have to be producing valid XHTML to begin with, or tidy could nuke other parts of your document.
I have a weird problem. Using XSLT transformations with PHP and for some reason, the compiled template file that is printed to the user strips all comments from the code. This never occurred before and have been unable to debug this problem at all. Even at the source $xslt->transformToXML($xml), it is stripped comments now, when it wasn't before.
This is particularly annoying with JS blocks that are wrapped in <!-- -->.
Any ideas?
As far as I know, unless you tell it otherwise, an XSLT transform will strip comments and processing instructions.
If you want to keep comments you can add something like
<xsl:template match="comment()">
<xsl:comment><xsl:value-of select="."/></xsl:comment>
</xsl:template>
to your xslt file.
How do I allow the marquee tag in html purifier http://htmlpurifier.org/ I read the docs but I couldn't find anything. Does any one have a clue?
Marquee is not, and was ever, a valid HTML tag, so HTML Purifier doesn't support it even if you set HTML.Allowed. You'll have to follow the instructions here to add support for it: http://htmlpurifier.org/docs/enduser-customize.html