A page containing a good load of javascript also contains URLs encoded within the javascript as JS strings.
The problem is that Chrome (or perhaps just it's Developer Tools?) is trying to navigate to these encoded URLs as if they were a part of the HTML.
This only seem开发者_运维百科s to happen when there is a lot of javascript in the page.
The page looks more or less like:
<body>
....
<script type="text/javascript">
//<![CDATA[
google.maps.event.clearListeners(window.kgmm["marker32"],"click");
google.maps.event.addListener(window.kgmm["marker32"],"click",clicked);
window.kgmp["marker54"]=new InfoBox({
content: "<div class=\"wrapBox\" align=\"left\"><div class=\"imageBox\"><a href=\"#ir_rih\" target=\"_blank\"><span class=\"imageWrap\">"
/* the issue -> */ +"<img src=\"?ajax=1&cls=owAjaxHandler&mtd=thumbnail&i=wp-content\/uploads\/2011\/07\/Bahrija & Fomm ir-rih08.jpg&w=115&h=115\" border=\"0\" alt=\"\"\/><\/"
+"span><\/a><\/div><div class=\"specsBox\"><h2>Fomm Ir-Rih<\/h2><div class=\"shortDesc\"><\/div><a class=\"moreInfo\" href=\"#ir_rih\" onclick=\"return krtShowTabByHash(this);\">more details »<\/a><\/div><\/div>" ,
disableAutoPan: false,
maxWidth: 0,
pixelOffset: new google.maps.Size(-214, 0),
zIndex: null
});
//]]>
</script>
....
</body>
The following is a screenshot on how it looks like in the console:
Be warned that I'm not looking for a fix. Please don't advise on any way to improve the code.
Rather than a fix, I'm looking for an answer as to why this is happening.
NB: Wasn't CDATA supposed to stop chrome from parsing the javascript contents as XML elements?
Sample URL causing the issue:
- First, go here.
- Open the console (
Right Click -> Inspect Element -> Console tab
) - Click on the second item in the page list, named "Mdina, Rabat, Dingli & Baħrija"
- Keep looking at the console while the page loads, you should see the aforementioned errors.
NB: Someone has marked the question as "too localized". I'd like to point out that that is not true. I've encountered this issue on multiple websites,but never gave it much thought (until now) because the website still works.
I'd put dollars to donuts that the problem is your escaping of the i
url parameter:
src=\"?ajax=1&cls=owAjaxHandler&mtd=thumbnail&i=wp-content\/uploads\/2011\/07\/Bahrija & Fomm ir-rih08.jpg&w=115&h=115\"
Basically, backslash escaping does not work for URLs. If you wanted to go to that URL, you'd need to send it as:
src=\"?ajax=1&cls=owAjaxHandler&mtd=thumbnail&i=wp-content%2Fuploads%2F2011%2F07%2FBahrija%20%26%20Fomm%20ir-rih08.jpg&w=115&h=115\"
Chris Edit: Decoding it as a javascript string would yield:
src="?ajax=1&cls=owAjaxHandler&mtd=thumbnail&i=wp-content/uploads/2011/07/Bahrija & Fomm ir-rih08.jpg&w=115&h=115"
精彩评论