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()">
<span id="Pages"></span>
<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
- var bodyObj,articleBody,currentPage;
- var pageArray=new Array();
- var pageAnchor=" <a id='page_[num]' href='javascript:SetPageNumber([num])'>[num]</a> ";
- var regEx=new RegExp("(?:(?:\\[\\[SNewPage\\]\\])|^)([\\s\\S]*?)(?:(?=\\[\\[SNewPage\\]\\])|$)","ig");
- function ManagePages()
- {
- bodyObj=document.getElementById("literal");
- articleBody=bodyObj.innerHTML;
- bodyObj.innerHTML="";
- regResult=regEx.exec(articleBody);
- while(regResult!=null)
- {
- pageArray.push(regResult[1]);
- regResult=regEx.exec(articleBody);
- }
- for(i=1;i<=pageArray.length;i++)
- {
- Pages.innerHTML+=pageAnchor.replace("[num]",i).replace("[num]",i).replace("[num]",i);
- }
- SetPageNumber(1);
- if (pageArray.length==1)
- pageBrowser.style.display='none';
- }
- function SetPageNumber(num)
- {
- if(num>pageArray.length || num < 1 || num == currentPage)
- return;
- if(num==1)
- {
- document.all["NavigatePre"].onclick=null;
- document.all["NavigateFirst"].onclick=null;
- document.all["NavigatePre"].style.cursor='auto';
- document.all["NavigateFirst"].style.cursor='auto';
- }
- else
- {
- document.all["NavigatePre"].onclick=PreviousPage;
- document.all["NavigateFirst"].onclick=FirstPage;
- document.all["NavigatePre"].style.cursor='hand';
- document.all["NavigateFirst"].style.cursor='hand';
- }
- if(num==pageArray.length)
- {
- document.all["NavigateLast"].onclick=null;
- document.all["NavigateNext"].onclick=null;
- document.all["NavigateLast"].style.cursor='auto';
- document.all["NavigateNext"].style.cursor='auto';
- }
- else
- {
- document.all["NavigateLast"].onclick=LastPage;
- document.all["NavigateNext"].onclick=NextPage;
- document.all["NavigateLast"].style.cursor='hand';
- document.all["NavigateNext"].style.cursor='hand';
- }
- bodyObj.innerHTML=pageArray[num-1];
- currentPage=num;
- window.scroll(0,200);
- }
- function FirstPage()
- {
- SetPageNumber(1);
- }
- function PreviousPage()
- {
- SetPageNumber(currentPage-1);
- }
- function NextPage()
- {
- SetPageNumber(currentPage+1);
- }
- function LastPage()
- {
- SetPageNumber(pageArray.length);
- }
and now, what should i do, and what's the problem?