Browser automatically looks up image URL from JS source

夙愿已清 提交于 2019-12-25 00:38:25

问题


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 google.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.

来源:https://stackoverflow.com/questions/5728280/browser-automatically-looks-up-image-url-from-js-source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!