473,387 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

InnerHtml problem in firefox i think?

2
hi everyone
i'm using some regular expression to paging, it work's fine in IE but not in Firefox
i removed every thing to detect problem but i Can't , the only thing i got, is the innerHtml doent work as it should
here is my page:
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script language="javascript" type="text/javascript" src="ViewArticle.aspx_files/scripts.js"></script>

</head>
<body dir="rtl">
<div class="padContent" id="literal">
page 1
<br />
[[SNewPage]] Page 2
<br />
[[SNewPage]] page 3
</div>
<img alt="صفحه نخست" class="IndentElement" src="ViewArticle.aspx_files/imageslast.gif"
id="NavigateFirst" style="" onclick="FirstPage()">
<img alt="صفحه قبل" src="ViewArticle.aspx_files/imagesprev.gif" id="NavigatePre"
style="" onclick="PreviousPage()">
&nbsp;&nbsp; <span id="Pages"></span>&nbsp;&nbsp;
<img alt="صفحه بعد" src="ViewArticle.aspx_files/imagesnext.gif" id="NavigateNext"
style="" onclick="NextPage()">
<img alt="صفحه آخر" src="ViewArticle.aspx_files/imagesfirst.gif" id="NavigateLast"
style="" onclick="LastPage()">
<script language="javascript" type="text/javascript">
ManagePages();
</script>
</body>
</html>[/HTML]

and here is my script File Content:
Expand|Select|Wrap|Line Numbers
  1.      var bodyObj,articleBody,currentPage;
  2.      var pageArray=new Array();
  3.      var pageAnchor="&nbsp;<a id='page_[num]' href='javascript:SetPageNumber([num])'>[num]</a>&nbsp;";     
  4.      var regEx=new RegExp("(?:(?:\\[\\[SNewPage\\]\\])|^)([\\s\\S]*?)(?:(?=\\[\\[SNewPage\\]\\])|$)","ig");
  5.  
  6.  function ManagePages()
  7.  {
  8.         bodyObj=document.getElementById("literal");
  9.         articleBody=bodyObj.innerHTML;
  10.         bodyObj.innerHTML="";        
  11.         regResult=regEx.exec(articleBody);
  12.  
  13.     while(regResult!=null)
  14.     {
  15.         pageArray.push(regResult[1]);
  16.         regResult=regEx.exec(articleBody);
  17.     }
  18.  
  19.     for(i=1;i<=pageArray.length;i++)
  20.      {
  21.         Pages.innerHTML+=pageAnchor.replace("[num]",i).replace("[num]",i).replace("[num]",i);
  22.      }
  23.      SetPageNumber(1);
  24.      if (pageArray.length==1)
  25.         pageBrowser.style.display='none';
  26.  } 
  27.  
  28. function SetPageNumber(num)
  29.  {
  30.     if(num>pageArray.length || num < 1 || num == currentPage)
  31.         return;
  32.  
  33.     if(num==1)
  34.     {
  35.     document.all["NavigatePre"].onclick=null;
  36.     document.all["NavigateFirst"].onclick=null;
  37.     document.all["NavigatePre"].style.cursor='auto';
  38.     document.all["NavigateFirst"].style.cursor='auto';
  39.     }
  40.     else
  41.     {
  42.     document.all["NavigatePre"].onclick=PreviousPage;
  43.     document.all["NavigateFirst"].onclick=FirstPage;
  44.     document.all["NavigatePre"].style.cursor='hand';
  45.     document.all["NavigateFirst"].style.cursor='hand';
  46.     }
  47.  
  48.     if(num==pageArray.length)
  49.     {
  50.     document.all["NavigateLast"].onclick=null;
  51.     document.all["NavigateNext"].onclick=null;
  52.     document.all["NavigateLast"].style.cursor='auto';
  53.     document.all["NavigateNext"].style.cursor='auto';
  54.     }
  55.     else
  56.     {
  57.         document.all["NavigateLast"].onclick=LastPage;
  58.     document.all["NavigateNext"].onclick=NextPage;
  59.     document.all["NavigateLast"].style.cursor='hand';
  60.     document.all["NavigateNext"].style.cursor='hand';
  61.     }
  62.     bodyObj.innerHTML=pageArray[num-1];
  63.     currentPage=num;
  64.     window.scroll(0,200);
  65.  }
  66.      function FirstPage()
  67.      {
  68.         SetPageNumber(1);
  69.      }
  70.      function PreviousPage()
  71.      {
  72.      SetPageNumber(currentPage-1);
  73.      }
  74.      function NextPage()
  75.      {
  76.      SetPageNumber(currentPage+1);
  77.      }
  78.      function LastPage()
  79.      {
  80.         SetPageNumber(pageArray.length);
  81.      }

and now, what should i do, and what's the problem?
Dec 21 '06 #1
2 2711
b1randon
171 Expert 100+
hi everyone
i'm using some regular expression to paging, it work's fine in IE but not in Firefox
i removed every thing to detect problem but i Can't , the only thing i got, is the innerHtml doent work as it should
here is my page:
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script language="javascript" type="text/javascript" src="ViewArticle.aspx_files/scripts.js"></script>

</head>
<body dir="rtl">
<div class="padContent" id="literal">
page 1
<br />
[[SNewPage]] Page 2
<br />
[[SNewPage]] page 3
</div>
<img alt="صفحه نخست" class="IndentElement" src="ViewArticle.aspx_files/imageslast.gif"
id="NavigateFirst" style="" onclick="FirstPage()">
<img alt="صفحه قبل" src="ViewArticle.aspx_files/imagesprev.gif" id="NavigatePre"
style="" onclick="PreviousPage()">
&nbsp;&nbsp; <span id="Pages"></span>&nbsp;&nbsp;
<img alt="صفحه بعد" src="ViewArticle.aspx_files/imagesnext.gif" id="NavigateNext"
style="" onclick="NextPage()">
<img alt="صفحه آخر" src="ViewArticle.aspx_files/imagesfirst.gif" id="NavigateLast"
style="" onclick="LastPage()">
<script language="javascript" type="text/javascript">
ManagePages();
</script>
</body>
</html>[/HTML]

and here is my script File Content:
Expand|Select|Wrap|Line Numbers
  1.      var bodyObj,articleBody,currentPage;
  2.      var pageArray=new Array();
  3.      var pageAnchor="&nbsp;<a id='page_[num]' href='javascript:SetPageNumber([num])'>[num]</a>&nbsp;";     
  4.      var regEx=new RegExp("(?:(?:\\[\\[SNewPage\\]\\])|^)([\\s\\S]*?)(?:(?=\\[\\[SNewPage\\]\\])|$)","ig");
  5.  
  6.  function ManagePages()
  7.  {
  8.         bodyObj=document.getElementById("literal");
  9.         articleBody=bodyObj.innerHTML;
  10.         bodyObj.innerHTML="";        
  11.         regResult=regEx.exec(articleBody);
  12.  
  13.     while(regResult!=null)
  14.     {
  15.         pageArray.push(regResult[1]);
  16.         regResult=regEx.exec(articleBody);
  17.     }
  18.  
  19.     for(i=1;i<=pageArray.length;i++)
  20.      {
  21.         Pages.innerHTML+=pageAnchor.replace("[num]",i).replace("[num]",i).replace("[num]",i);
  22.      }
  23.      SetPageNumber(1);
  24.      if (pageArray.length==1)
  25.         pageBrowser.style.display='none';
  26.  } 
  27.  
  28. function SetPageNumber(num)
  29.  {
  30.     if(num>pageArray.length || num < 1 || num == currentPage)
  31.         return;
  32.  
  33.     if(num==1)
  34.     {
  35.     document.all["NavigatePre"].onclick=null;
  36.     document.all["NavigateFirst"].onclick=null;
  37.     document.all["NavigatePre"].style.cursor='auto';
  38.     document.all["NavigateFirst"].style.cursor='auto';
  39.     }
  40.     else
  41.     {
  42.     document.all["NavigatePre"].onclick=PreviousPage;
  43.     document.all["NavigateFirst"].onclick=FirstPage;
  44.     document.all["NavigatePre"].style.cursor='hand';
  45.     document.all["NavigateFirst"].style.cursor='hand';
  46.     }
  47.  
  48.     if(num==pageArray.length)
  49.     {
  50.     document.all["NavigateLast"].onclick=null;
  51.     document.all["NavigateNext"].onclick=null;
  52.     document.all["NavigateLast"].style.cursor='auto';
  53.     document.all["NavigateNext"].style.cursor='auto';
  54.     }
  55.     else
  56.     {
  57.         document.all["NavigateLast"].onclick=LastPage;
  58.     document.all["NavigateNext"].onclick=NextPage;
  59.     document.all["NavigateLast"].style.cursor='hand';
  60.     document.all["NavigateNext"].style.cursor='hand';
  61.     }
  62.     bodyObj.innerHTML=pageArray[num-1];
  63.     currentPage=num;
  64.     window.scroll(0,200);
  65.  }
  66.      function FirstPage()
  67.      {
  68.         SetPageNumber(1);
  69.      }
  70.      function PreviousPage()
  71.      {
  72.      SetPageNumber(currentPage-1);
  73.      }
  74.      function NextPage()
  75.      {
  76.      SetPageNumber(currentPage+1);
  77.      }
  78.      function LastPage()
  79.      {
  80.         SetPageNumber(pageArray.length);
  81.      }

and now, what should i do, and what's the problem?
Wow, someone has taught you the evil Microsoft-y way to do javascript. You've got to follow the w3c standards if you want your script to be supported. I got your script working. Here's what you need to change:

1. Any reference to document.all - that's bad, only IE does that. Use document.getElementById('id') instead like this:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('NavigateNext').style.cursor='hand';
  2.  
2. You can't just refer to an object by its id - you've got to use getElementById:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('Pages').innerHTML+=pageAnchor.replace("[num]",i).replace("[num]",i).replace("[num]",i);
  2.  
Fix those in all the places you've done them and your script will go alright.
Dec 21 '06 #2
ars
2
thankx a lot, for your kindy and fast help.

it's realy solved my problem.
Dec 22 '06 #3

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

Similar topics

14
by: catorcio | last post by:
I'm trying to have some text in my page changed by clicking a button. Googleing around I've discovered that innerText doesn't work with every browser, so I've switched to innerHTML. It works fine...
10
by: Jake Barnes | last post by:
This weekend I wanted to learn AJAX, so I set up a little toy page where I could experiment. The idea of this page is that you click in one of the boxes to get some controls, at which point you can...
9
by: Hallvard B Furuseth | last post by:
Why does the FAQ (Q 4.15) recommend innerHTML when so many here say one should use createElement(), replaceChild() etc? Also, why does the "Alternative DynWrite function" at...
2
by: sveinn | last post by:
Hi all, I've read through this group searching for an answear about this problem. Few have come close but not quite what I need. My problem is this: I'm using Ajax to fetch a new table with...
7
by: Hoss | last post by:
Hello all- This is what im trying to achieve. At the top of my page there is some search functionality, through which you cause to be loaded a string representing an HTML page. Below this and...
4
by: tcole6 | last post by:
My problem appears to be Firefox specific. I have a hyperlink that loads a new window. This window contains hyperlinks that call javascript functions in the parent window and then closes the...
6
by: sonic | last post by:
Ok, i am sure everyone is sick of hearing about this. but i've checked about 10 different posts/sites about this issue, and they all say "use DOM" but i think there is more to be said. Perhaps I...
2
by: mypublicmail | last post by:
I'm moving big chunks of html into and out of divs using innerHTML. Or, I thought I was until I tested it on Firefox 1.5. Firefox will move the html just fine, but if you have changed any input...
6
by: PaPa | last post by:
I'm not sure this is a javascript issue or an HTML issue. I notice that when I extract the contents of a div using the innerHTML property (?), that I wind up with a literal variable (?) which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.