SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Italy
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Compatibility problems with a no public standard instruction

    Hi,
    I have some html/php pages with javascript code, running on a Apache server.
    The users access to those page by a WLAN connection; they use handhelds with Pocket PC and in particular they use the internet browser PIE (Pocket Internet Explorer).

    The pages don't work properly when the users access by a different internet browser (for example Opera of a Nokia 9500, always by a WLAN connection)

    The problem is the following code, that seems to be compatible only with microsoft browser:
    ___________________________________
    <SCRIPT language="javascript" >
    function clicked(button)
    {
    if ( display.innerText!=0 && display.innerText<100 ) display.innerText += button ;
    else display.innerText= button ;
    window.focus();
    }
    </SCRIPT>


    <div id="display" name="display">0</div>

    ___________________________________

    When some buttons of the page are clicked, the function "clicked" is called and the value of the number between <div></div> changes.


    I suppose that some javascript command inside the function "clicked" are not standard, and I think that it's the command "innerText"; in fact, on the Microsoft (MSDN) web page, I found out about "innerText" that "There is no public standard that applies to this property".

    The other javascript codes seem work properly also with not PIE browser.

    Any suggestion in order to perform the same target of the function "clicked" using public standard?

    Thank You in Advance
    Fausto

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    innerHTML is also not part of any standard, but it has better cross-browser support.

    You could also use DOM1 methods.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Italy
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    first of all for the your reply---
    sorry but I'm not so expert and I dind't understand the you reply...

    What is the DOM1 method?

    Thank you
    Fausto

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure I understand how it's supposed to work, but this could be a start:

    Code:
    <script type="text/javascript">
      function clicked(button)
      {
        var  display = document.getElementById("display").firstChild;
        var  n = parseInt(display.data, 10);
    
        if (n != 0 && n < 100) {
          n += parseInt(button, 10);
          display.replaceData(0, display.length, n);
        } else {
          display.replaceData(0, display.length, button);
        }
      }
    </script>
    Birnam wood is come to Dunsinane

  5. #5
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IE's innerText property is not widely supported, however, innerHTML is.

    Thanks, Tommy.

    It might be a good idea to check which type of node the first child is.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  6. #6
    SitePoint Guru
    Join Date
    Feb 2005
    Posts
    602
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Google DOM 1

  7. #7
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kravvitz
    It might be a good idea to check which type of node the first child is.
    Agreed, but since the code looked like this
    Code:
    <div id="display" name="display">0</div>
    there didn't seem to be much ambiguity.

    BTW, lose the 'name' attribute. It's not valid for the DIV element type.
    Birnam wood is come to Dunsinane

  8. #8
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Italy
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi to everybody,
    collecting the your suggestions I used the following code:
    ____________________________________________
    <script type="text/javascript">
    function clicked(button)
    {
    var display = document.getElementById("display").firstChild;
    var n=display.data ;

    if ( n!= 0 && n<100 )
    {
    n = 10 * n + button ;
    display.replaceData(0, display.length, n);
    }
    else { display.replaceData(0, display.length, button ); }
    }

    </script>

    <div id="display" >0</div>
    _________________________________________________


    For all the used instructions in the code above, the MS site report "This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1", therefore all the instructions should be standard instructions.

    The code works properly using Microsoft Internet Explorer, but it continue to not work on the "Opera" browser on my Nokia 9500.
    I don't know why it doesn't work, but I can only suppose that the Opera browser for Nokia 9500 has a limited set of instructions and some of them is inside the my code...

    Ciao
    Fausto


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
  •