开发者

Browser automatically looks up image URL from JS source

I'm not sure of a better way to describe my problem. I have the following JS code repeated a couple of times:

window.kgmp["marker23"]=new InfoBox({
    content: "<div class=\"wrapBox\" align=\"left\"><div class=\"imageBox\"><span class=\"imageWrap\"><img src=\"http:\/\/www.MYSITE.com\/wp-content\/uploads\/2011\/04\/Hellespont (3).jpg\" alt=\"\"\/><\/span><\/div><div class=\"specsBox\"><h2>HMS Hellespont<\/h2><div class=\"shortDesc\"><p>one of the last steam paddle tugs to be built, forgotten till the late 1990\u2019s.<\/p><\/div><a class=\"moreInfo\" href=\"javascript:showMarker(23);\">more details &raquo;<\/a><\/div><\/div>",
    disableAutoPan: false,
    maxWidth: 0,
    pixelOffset: new googl开发者_C百科e.maps.Size(-134, 0),
    zIndex: null,
    boxStyle: {
        background: "",
        border: "none",
        font: "12px Georgia",
        width: "249px",
        height: "115px",
        padding: "20px 10px 10px 10px",
        position: "absolute"
    },
    closeBoxURL: "",
    infoBoxClearance: new google.maps.Size(1, 1),
    isHidden: false,
    pane: "floatPane",
    enableEventPropagation: false
});

NB: This is generated code; which explains why there are some bad formatting practices (such as long lines and a lot of literals). The markers are stored in a global variable for several reasons, no need to go on with the "global variables are evil mantra", thanks.

So, where is the problem?

After running the page a few times, with 2 or more of the above code, I started noting a lot of 404 errors in Firebug, one of which is:

"NetworkError: 404 Not Found - http://www.MYWEBSITE.com/user/holiday-planner/%5C%22http:%5C/%5C/www.MYWEBSITE.com%5C/wp-content%5C/uploads%5C/2011%5C/04%5C/Hellespont"

Here are some key points to note:

  • The image is not referenced anywhere else.
  • The HTML containing the image works perfectly (when invoked).
  • The image URL in the 404 error is wrong. It is relative to the current page the user is on (http://www.MYSITE.com/user/holiday-planner/5-marsascala-zejtun-marsaxlokk-birzebbugia).
  • From the javascript part, it seems the code is properly encode, and I don't get any JS errors whatsoever.
  • I tried using CDATA, to no avail. Then again, that's better since I don't like CDATA crap.
  • I'm testing this on Firefox 3.6. Will try it on others in a few mins...Chrome and Safari seem immune to the issue.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜