Description: It is very practical to use the Array set of js scripts, especially when you build your own framework. <script>
Function
GoUrl (urlItem, obj)
{
Var
HpageIndex = 0 ;//
Defines the maximum index for storing the URL address set
Var
HpageLength = 0 ;//
Specify the length of the set of stored URLs.
Var
HpageUrl = new
Array ();//
Define a set of stored URLs
HpageIndex
= Parent. window. pageIndex ;//
Obtains the maximum index of the URL set (global variable of the parent page)
HpageLength
= Parent. window. pageLength ;//
Obtains the total length of the URL set (the global variable of the parent page)
HpageUrl
= Parent. window. pageUrl ;//
Get the URL address set (global variable of the parent page)
Var
UrlPath = parent.doc ument. getElementById ('mainframework'). src ;//
Obtain the page currently accessed by the main framework (the address of the page specified by src of the main framework MainFrame)
///
Refresh event judgment
If (urlItem
=''
& Obj = '')
{
UrlPath
= Parent.doc ument. getElementById ('mainframework'). src ;//
To avoid exceptions, re-obtain the page currently accessed by the main framework.
Parent.doc ument. getElementById ('mainframework'). src
= UrlPath ;//
Set the page to be accessed by the main framework
}
///
Homepage event processing
Else
If (urlItem
= '0'
& Obj = '0 ')
{
UrlPath
= HpageUrl [0]; //
Obtain the first value in the Set (you can also define the homepage stored when the page is loaded)
Parent.doc ument. getElementById ('mainframework'). src
= UrlPath ;//
Set the page to be accessed by the main framework
}
///
Processing of page access history events
Else
If (urlItem
= '-1'
& Obj = '-1 ')
{
//
Determines whether the URL address set (global variable) is null.
If (parent. window. pageUrl
! = Null ){
//
Determines whether the length of the set is 1. If yes, the access history is 1.
If
(Parent. window. pageUrl. length = 1)
UrlPath
= Parent. window. pageUrl [0];
//
Judge whether the length of the set is greater than 1. If yes, judge the access history cyclically.
Else
If
(Parent. window. pageUrl. length> 1 ){
//
Cyclic access history address set
For (var
I = 0; I <HpageUrl. length; I ++ ){
//
Determines whether it is equal to the address of the currently accessed page
If (urlPath = HpageUrl [I])
{
//
Determines whether to return to the first address. If yes, the first address is obtained directly.
If (I-1)
<= 0)
{
UrlPath
= HpageUrl [0];
Break;
}
Else
{
UrlPath
= HpageUrl [I-1]; //
Obtain the record of the previous access address with the same current access address
Break;
}
}
}
}
}
If (urlPath
= '')//
Checks whether the historical access record address is null. If it is null, the current address of the main framework is returned.
UrlPath
= Parent.doc ument. getElementById ('mainframework'). src;
Parent.doc ument. getElementById ('mainframework'). src
= UrlPath ;//
Set the page to be accessed by the main framework
}
//
Handling of forward page access history events
Else
If (urlItem
= '1'
& Obj = '1 ')
{
//
Determines whether the URL address set (global variable) is null.
If (parent. window. pageUrl
! = Null ){
//
Determines whether the length of the set is 1. If yes, the access history is 1.
If
(Parent. window. pageUrl. length = 1)
UrlPath
= Parent. window. pageUrl [0];
//
Judge whether the length of the set is greater than 1. If yes, judge the access history cyclically.
Else
If
(Parent. window. pageUrl. length> 1 ){
//
Cyclic access history address set
For (var
I = 0; I <HpageUrl. length; I ++ ){
//
Determines whether it is equal to the address of the currently accessed page
If (urlPath = HpageUrl [I])
{
//
Determine whether to move forward to the last address.
If (I + 1)
> = Parent. window. pageUrl. length)
{
UrlPath
= HpageUrl [I];
Break;
}
Else
{
UrlPath
= HpageUrl [I + 1]; //
Obtain the next access address record with the same current access address
Break;
}
}
}
}
}
If (urlPath
= '')//
Checks whether the historical access record address is null. If it is null, the current address of the main framework is returned.
UrlPath
= Parent.doc ument. getElementById ('mainframework'). src;
Parent.doc ument. getElementById ('mainframework'). src
= UrlPath ;//
Set the page to be accessed by the main framework
}
Else
{
UrlPath
= "Default. aspx? "+ UrlItem ;//
Set the page address to be accessed by the event
Parent.doc ument. getElementById ('mainframework'). src
= UrlPath ;//
Set the page to be accessed by the main framework
UrlPath
= Parent.doc ument. getElementById ('mainframework'). src;
//
Re-obtain the page to be accessed by the main framework
HpageUrl [HpageIndex
+ 1] = urlPath ;//
Add the currently accessed page address to the address set of the temporary page URL
Parent. window. pageIndex
= HpageIndex + 1 ;//
Set global maximum Index
Parent. window. pageLength
= HpageLength + 1 ;//
Set the length of the global set
Parent. window. pageUrl
= HpageUrl ;//
Set global set data
// Alert ('current access :'
+ UrlPath + 'pageurl. Length: '+ HpageUrl. length, + '');
}
}
</Script>
Author: WuWenji_ZhaoLinQing