SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XHTML javascript image swap conflict

    Hi,

    I am using a simple javascript image insertion on my XHTML page, and I have encountered a problem. The Javascript code fails to execute when the doctype is XHTML on Firefox (works on Opera). However, when I simply rename the file with an HTML extension, the code executes on all browsers.

    This link is to the markup:

    http://www.themodernpet.com/redesign...tatement.xhtml
    http://www.themodernpet.com/redesign...statement.html

    This is the javascript code:

    function init3() {
    var myWidth=alertSize();
    if (myWidth >= 1271)
    {var x='1400'}
    if (myWidth <= 1270 && myWidth >= 1015)
    {var x='1280'}
    if (myWidth <= 1014 && myWidth >= 791)
    {var x='1024'}
    if (myWidth <= 790)
    {var x='0800'}
    window.document.logo_pic.src=('images/' + x + '/main/logopainting_small.jpg');
    window.document.banner_pic.src=('images/' + x + '/main/themodernpet.jpg');
    window.document.gifts.src=('images/' + x + '/main/gift_ideas.jpg');
    window.document.contests.src=('images/' + x + '/main/contest.jpg');
    window.document.sizing.src=('images/' + x + '/main/sizing_guide.jpg');
    window.document.privacy_statement.src=('images/' + x + '/main/privacy_statement.jpg');
    }


    function alertSize() {
    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth + 21;
    myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth + 21;
    myHeight = document.body.clientHeight;
    }
    return myWidth
    }

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Remove the following from 'minmax.js' (at the end of the file):
    Code:
    -----------------------------28734694826511
    Content-Disposition: form-data; name="userfile"; filename=""
    Content-Type: application/octet-stream
    and then we can go from there.

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the javascript code:
    Ahhh. A big fib.

    Nice catch, Mike.

  4. #4
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    those lines appear to be generated as a tag by the hosting, and are not a part of the file proper, rather just a part of the view source.

    They definitely aren't in the file I'm uploading. Thanks for looking, though.

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But they are causing a syntax error, or at least that's what Firebug is telling me. Talk to your hosting provider and ask them why they feel fit to modify a document that is copyrighted by you.

    Dave

  6. #6
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thanks

    I am looking into that, but it isn't the only problem. When I run the files on my computer without that code the javascript still fails to execute.

  7. #7
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    those lines appear to be generated as a tag by the hosting, and are not a part of the file proper, rather just a part of the view source.
    Ever thought of becoming a politician?

    "The $200 billion we are spending is not part of the budget--it's off balance sheet debt."

    I am looking into that, but it isn't the only problem. When I run the files on my computer without that code the javascript still fails to execute.
    Post the minimum amount of code that will produce the problem you are seeing. Then describe the expected results and the actual results.


Bookmarks

Posting Permissions

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