469,306 Members | 2,064 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Javascript only works in IE, not in Fire Fox or Chrome

matheussousuke
249 100+
I have this script here that works with IE8, but not with Fire Fox and Chrome:


Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. var it=0
  4. function initialize(){
  5. mytext=typing.innerText
  6. var myheight=typing.offsetHeight
  7. typing.innerText=''
  8. document.all.typing.style.height=myheight
  9. document.all.typing.style.visibility="visible"
  10. typeit()
  11. }
  12. function typeit(){
  13. typing.insertAdjacentText("beforeEnd",mytext.charAt(it))
  14. if (it<mytext.length-1){
  15. it++
  16. setTimeout("typeit()",100)
  17. }
  18. else
  19. return
  20. }
  21. if (document.all)
  22. document.body.onload=initialize
  23.  
  24. </script>
  25.  
  26. <span id="typing" style="visibility:hidden" align="left"><?=$st?></span>
  27.     <br>
  28. <?
  29. }
  30. ?>
  31. <br><br><a class=TN href=story.php> <?=$STORY2?></a>
  32.  


Is that a incompatibility issue?
Oct 6 '11 #1
4 2644
Dormilich
8,651 Expert Mod 8TB
kind of. document.all and .innerText are Microsoft proprietary additions to JavaScript. additionally, only in IE IDs and names are automatically added to the gobal scope. all other browsers use document.getElementById() and document.getElementsByName().
Oct 7 '11 #2
matheussousuke
249 100+
Thx again, Dormilich, you're always helping me.
I noticed that, remembered about some issues I had with IE behaviors in the past, nothing in FF or Chrome, but working IE. Too bad.

I found another script that can make the same task and runs in every browser.
Oct 7 '11 #3
drhowarddrfine
7,435 Expert 4TB
Always remember the web developer's mantra: "If it works in IE, but not the modern browsers, then there's something wrong with the code", and never, ever trust IE to do anything right.
Oct 7 '11 #4
matheussousuke
249 100+
God yeah. Definitely.
Oct 7 '11 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Vik Rubenfeld | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.