Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    884
    Thanks
    53
    Thanked 6 Times in 5 Posts

    setting a property that has only a getter

    I am sorry the following code is a bit of a mouthful, but I can't find a better way to display the problem.

    The code works as expected in Chrome, but not in IE and FF. In IE the error is "Object doesn't support this action" and in FF "setting a property that has only a getter". In Chrome there is no error in the console.

    There are three javascript <script>...</script>s that exist to display a <td> row in a table with a particular graphic depending on the screen width.

    The odd thing is that in both IE and FF (and of course Chrome), the first two scripts display perfectly well.

    Why does the third <script> produce an error?

    It has exactly the same form as the two before it.

    I can only guess it has something to do with where it occurs

    Googling the FF error, it has something to do with trying to set a read-only property, but then why do the first two <scripts> work? They are no different (at least I can't see a difference.)

    Code:
    <table border="0" width="100%" cellpadding="0" style="border-collapse: collapse" id="table3768">
    <script>
    if (screen.width > 1280) {
    document.write("<td valign=\"top\" background=\"..\/..\/img\/lesson2.gif\" width=\"840\" height=\"301\">");
    }
    else {
    document.write("<td valign=\"top\" background=\"..\/..\/img\/lesson.gif\" width=\"369\" height=\"301\">");
    }
    </script>
    <p>&nbsp;</p>
    <div align="left">
    </table>
    <table border="0" style="border-collapse: collapse" cellpadding="15">
    <tr>
    <td width="40">&nbsp;</td>
    <script>
    if (screen.width > 1280) {
    document.write("<td width=\"300\">");
    }
    else {
    document.write("<td width=\"165\">");
    }
    </script>
    <font face="Trebuchet MS" color="#808000">Today's lesson is about setting 
    goals...</font></td>
    </tr>
    </table>
    </div>
    </td>
    <td rowspan="3">
    <table border="0" cellspacing="0" style="border-collapse: collapse" cellpadding="0" id="table3920">
    <tr>
    <td><img border="0" src="../../img/teltopw.jpg" width="550" height="9"></td>
    </tr>
    <tr>
    <td background="../../img/telbarw.jpg">
    <p align="center">
    <iframe name="ITV" src="lesson1TV.html" marginwidth="0" marginheight="0" scrolling="no" border="0" frameborder="0" width="480" height="376">
    Your browser does not support inline frames or is currently configured 
    not to display inline frames.
    </iframe></p>
    </td>
    </tr>
    <tr>
    <td><img border="0" src="../../img/telbotw.jpg" width="550" height="11"></td>
    </tr>
    </table>
    </td>
    <td align="center">
    <a target="_blank" href="http://www.apple.com/quicktime/download/">
    <img border="0" src="../../img/quicktimeani.gif" width="129" height="184"></a></td>
    </tr>
    <tr>
    <script>
    if ((screen.width = 1440) || (screen.width = 1400)) {
    document.writeln("<td valign=\"top\" width=\"100%\" background=\"\/images\/101online\/listening\/lesson16\/notebot2.gif\" width=\"450\" height=\"50\">");
    }
    else if (screen.width <= 1280) {
    document.writeln("<td valign=\"top\" width=\"100%\" background=\"\/images\/101online\/listening\/lesson16\/notebot.gif\" width=\"294\" height=\"50\">");;
    }
    </script>
    </td>
    <td valign="bottom">&nbsp;</td>
    </tr>
    <tr>
    <td valign="bottom" width="100%">
    <div align="right">
    <table border="0" cellpadding="5" style="border-collapse: collapse" id="table3926">
    <tr>
    <td align="center">
    <a onmousedown="soundManager.play('piano','../../media/mp3/piano.mp3'); return true;" href="javascript: goFull('FULLSCREEN/lesson1full.html','info','width=1020,height=760,left=0,top=0,toolbar=no,scrollbars=no,status=no,directories=no,menubar=no,location=no,resizable=no');">
    <img src="../../img/poster1ani.gif" border="0" width="95" height="29"></a>
    <b><font size="1" face="Arial" color="#000080">&nbsp;ON DISK</font></b></td>
    <td align="center"><b><font size="1" face="Arial" color="#000080">OR
    </font></b>&nbsp;<a onmousedown="soundManager.play('piano','../../media/mp3/piano.mp3'); return true;" href="javascript: goFull('CDRIVE/lesson1Cfull.html','info','width=1020,height=760,left=0,top=0,toolbar=no,scrollbars=no,status=no,directories=no,menubar=no,location=no,resizable=no');"><img src="../../img/poster7.bmp" border="0" width="53" height="30"></a>
    <b><font size="1" face="Arial" color="#000080">&nbsp;DRIVE</font></b></td>
    </tr>
    </table>
    </div>
    </td>
    <td valign="bottom">
    <iframe name="sounds" src="../../pagesounds.html" width="160" height="66" marginwidth="1" marginheight="1" scrolling="no" border="0" frameborder="0">
    Your browser does not support inline frames or is currently configured not to display 
    inline frames.
    </iframe></td>
    </tr>
    </table>
    Any light on this would be most welcome!
    The difference between genius and stupidity is that genius has its limits. (Albert Einstein)

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,534
    Thanks
    3
    Thanked 512 Times in 499 Posts
    Code:
    if ((screen.width == 1440) || (screen.width == 1400)) {
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    884
    Thanks
    53
    Thanked 6 Times in 5 Posts
    Thanks Vic. Another egregious error of mine. Still, it's odd that Chrome is forgiving of this one.
    The difference between genius and stupidity is that genius has its limits. (Albert Einstein)

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,574
    Thanks
    80
    Thanked 4,620 Times in 4,583 Posts
    Yes, it does seem odd. I'd rate that as a bug in Chrome.

    Clearly, screen.width can't possibly be a user-modifiable value. So it's just meaningless to assign a value to screen.width. I suppose you can argue that "meaningless" isn't the same as "causes an error", but still... It's an odd choice by the Chrome team to not barf on that.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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