Results 1 to 7 of 7

Thread: Multi Script errors (expected char, object not supported)

  1. #1
    Join Date
    Feb 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Multi Script errors (expected char, object not supported)

    Hey,

    I've got some script from varies places played with it, added me own bits and such (first time working with JS by the way) so that a webpage will detect the screen resolution and change the page accordingly for the activdesktop at the school i work at.


    First it told me that I needed to add a ";" (highlighted in red), aha simple I thought, I added the semi colon where it said to do.

    Now it's telling me that the object doesn't support this action. I've been goin around and around like this for the past few days and have now decided that I shall have to durrender and ask for help.

    I know this will be something rather simple that I have missed and shall no doubt kick myself when someone solves it.



    Code:
    <script type="text/javascript">
    <!--
    if (screen.width <= 1024) {
    window.location = '1024x768.html';
    }
    
    else if (screen.width <= 1280) {
    window.location = '1280x1024.html';
    }
    
    else if (screen.width <= 1440); {
    window.location = '1440x900.html';
    }
    
    else { window.location='index2.html';
    }
    //-->
    </script>

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    This should work:
    Code:
    <script type="text/javascript">
    <!--
    if (screen.width <= 1024) {
      window.location = '1024x768.html';
    } else if (screen.width <= 1280) {
    window.location = '1280x1024.html';
    } else if (screen.width <= 1440) {
      window.location = '1440x900.html';
    } else {
      window.location='index2.html';
    }
    //-->
    </script>
    Jeremy | jfein.net

  3. #3
    Join Date
    Feb 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No joy I'm afraid, cheers for trying.

    Well in one way it worked, no more error messages, now the page just crashes, it refuses to load at all.

    Have I got the "window.location" part wrong maybe? I know theres a few ways of getting it to point to a file but that seemed the most common?

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    It seems to work for me. Mind putting an online example?
    Jeremy | jfein.net

  5. #5
    Join Date
    Feb 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Managed toget a moment to put it online. All it does for me is crash so not sure how much use it will be to you. Wondeirng if it's something to do with the school network. Here's the link

    http://www.hornsea.eriding.net/wall/1024x768demo.html

    Cheers

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    It redirected me to: http://www.hornsea.eriding.net/wall/1280x1024.html =/ Same in IE (7 and 8), Safari, Chrome, and Opera.
    Jeremy | jfein.net

  7. #7
    Join Date
    Feb 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ah right so its something to do with the network. Thanks very much! Like I said, knew it would be something stupid :P

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
  •