SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
-
Apr 28, 2005, 07:51 #1
- 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
-
Apr 28, 2005, 16:17 #2
- 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.
-
May 2, 2005, 03:26 #3
- 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
-
May 2, 2005, 04:29 #4
- 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
-
May 2, 2005, 14:45 #5
- 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.
-
May 2, 2005, 19:16 #6
- Join Date
- Feb 2005
- Posts
- 602
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Google DOM 1
-
May 2, 2005, 22:10 #7
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Kravvitz
Code:<div id="display" name="display">0</div>
BTW, lose the 'name' attribute. It's not valid for the DIV element type.Birnam wood is come to Dunsinane
-
May 4, 2005, 07:45 #8
- 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