Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript question -- Jeff? (IE6)

    Does anyone know how I can get Javascript to return the URL of a web site's Background image -- BUT, it cannot use the "location" object?

    This appears to be the key to the broken Images List -- as best I can tell. This is what I have come up with:

    1) IE6 tries to enforce Cross-Frame (and Cross-Zone?) Scripting Security in DHTML by restricting/preventing the reading of scripts in other domains (and other zones?).

    2) One of the mechanisms that IE uses to do this is by stopping the script and producing an ERROR whenever it hits the location object.

    This is from a complete SIMPLETONS perspective. I have NO knowledge of JavaScript and can barely program my VCR. BUT, I can recognize when something does not work like it is supposed to!!

    The specific lines that cause the imglist.htm file to crash when used in IE6 are these:

    var szSrcDocURL = docSrc.location.href;

    if (docSrc.location.pathname.length > 1)

    szBGUrl = szSrcDocURL.substring(0,szSrcDocURL.indexOf(docSrc .location.pathname)+1) + szBGUrl;

    It doesn't take a coding wizard to realize what is the same in all of those lines.

    The script can be made servicable by replacing the "location" lines -- but then it does not correctly retrieve the Background image.

    Is there another solution that maintains the integrity of the script function?? Thanks.

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript question -- Jeff? (IE6)

    Someone sent me this answer:

    var strUrl = document.imageName.src;
    strUrl = strUrl.substring( strUrl.lastIndexOf( '/' ) + 1 );

    I don't really understand JavaScript, but I was hoping someone here could help out.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Javascript question -- Jeff? (IE6)

    If you make these substitutions does it do any good?

    <table border=2 cellpadding=3><td>From:</td><td>To:</td><td>docSrc.location.href</td><td>docSrc.URL</td><td>docSrc.location.pathname</td><td>docSrc.parentWindow.location.pathname</td></table>
    I know these return the equivalent information and/or objects, I just don't know if they will make any difference in your configuration.

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript question -- Jeff? (IE6)

    Yes, the docSrc.URL is able to overcome the first hurdle -- we found that earlier. I have not tried "docSrc.parentWindow.location.pathname" -- but I remain skeptical because of that nasty "location" word in there. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Take a second to read the information on the new IE cum. update and see if you don't think this applies to the problem:
    _________________________________

    Cross Domain Verification via Cached Methods, Frames Cross Site Scripting & Improper Cross Domain Security Validation with Frames (CAN-2002-1254, CAN-2002-1187, CAN-2002-1215):

    The vulnerability results because it is possible to bypass Internet Explorer

  5. #5
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Long Beach, California, USA
    Posts
    1,912
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript question -- Jeff? (IE6)

    Jeff, if you are interested, take a peak at the involved HTML resource: C:%windir%webimglist.htm.

    The problems begin to occur towards the end here:

    var szBGUrl = docSrc.body.background;
    var szSrcDocURL = docSrc.location.href;
    if (szBGUrl != "") {
    // Fix up szBGUrl if it has a leading slash (otherwise the string being created below has an embedded "//")...

    Again, the first hurdle is overcome by using: "var szSrcDocURL = docSrc.URL;". But, if you come to a site that actually uses a background image, the next hurdle that pops up is:

    szBGUrl = szSrcDocURL.substring(0,szSrcDocURL.indexOf(docSrc .location.pathname)+1) + szBGUrl;

    We are working on another method -- and after testing out some more, I'll post it back here -- if you are interested.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •