Đỉnh NGUYỄN

life's a journey not a destination

5 cách điều hướng (navigate) URL với JavaScript

Leave a comment


1. Điều hướng đăng nhập

<script type="text/javascript">
    window.location.href = 'login.aspx?backurl=' + window.location.href;
</script>

2. Quay lại trang vừa xem

<script type="text/javascript">
    alert('back');
    window.history.back(-1);
</script>

3. Điều hướng trực tiếp

<script type="text/javascript">
    window.navigate('top.aspx');
</script>

4. Cách khác

<script type="text/javascript">
    self.location = 'top.aspx';
</script>

5. Hoặc cách khác

<script type="text/javascript">
    alert('Access Violation');
    top.location = 'error.aspx';
</script>
Advertisements

Author: dinhnn

Senior software developer, a technical leader. You can be reached at via email to dinhnguyenngoc@gmail.com, via my blog at dinhnguyenngoc.wordpress.com, and on Twitter @dinhnguyenngoc.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s