Refresh the browser

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.