Cara menggunakan change browser history javascript

Don’t you love snappy titles?!

Consider a sophisticated application such as webmail client. In essence, it’s a complex JavaScript program running on a single HTML page. The user loads the URL and is presented with a list of emails. They click a title and the email content is retrieved using Ajax and displayed. They now want to return to the email list; what do they do?…

…click the browser’s back button.

Bang. The application closes and returns to the page they were viewing prior to accessing the application. Or, if it’s a new browser tab, the back button is disabled and can’t be clicked.

So we have a problem. Our webmail client doesn’t support the one browser control most users understand. There are solutions. Some involve changing the hash mark (#name) in the URL so the state can be retained. It’s not perfect, but works in all browsers.

Fortunately, the problem has been addressed with the HTML5 history.pushState and history.replaceState methods in conjunction with the window.onpopstate event.

Try the history.pushState() demonstration page…

The technique is refreshingly simple:

  1. When the state changes, e.g. the user opens an email, history.pushState() is passed state information and executed. This enables the back button but — importantly — does not move the user from the page.
  2. You can run history.pushState() as many times as necessary, or modify the current state using history.replaceState().
  3. When the user clicks back (or forward), the window.onpopstate event is fired. A handler function can retrieve the associated state and display the appropriate screen.

The downside? Forget IE compatibility until v10 arrives. If you need to support IE9 and below, there are a number of shims including History.js and HTML5-History-API.

Let’s write some code. Assume you’ve just displayed the result of an Ajax request:


// Ajax request
...
// display result
...

// modify history
history.pushState(obj, title, url);

Where:

  • obj is any JavaScript object. You could use this to retain state information, e.g. { “view”: “EMAILCONTENT”, “item”: 123 };
  • title is an optional title
  • url is an optional URL. The URL can be anything — the browser won’t jump to that page, but could if the user reloaded the page or restarted their browser. In most cases, you’ll want to use parameters or a hash name, e.g. ?view=EMAILCONTENT&item=123; your application could analyze these values on start-up and return to the same place.

history.replaceState() has identical arguments and is only used if you want to replace the current state with a new one.

You now need a handler function which runs when the window popstate event fires following the browser’s back or next button being clicked:


window.addEventListener("popstate", function(e) {

	// URL location
	var location = document.location;

	// state
	var state = e.state;
	
	// return to last state
	if (state.view == "EMAILCONTENT") {
		...
	}

});

The URL location can be determined with document.location (document.location.search and document.location.hash return the parameters and hash name respectively).

The historic state object set by pushState() or replaceState() is obtained from the event object’s state property. You can use the information to display the appropriate screen.

Try the history.pushState() demonstration page…

Click the history.pushState button a few times then hit back to see what happens in the log.

Very useful. Have you encountered back and next button issues in your web application?

User Guide

  • All Categories
  • Tools and Gestures
  • Settings

How to reconnect to our servers

Puffin should auto-resume its connection to our server while your device recovering from no signal. You can enforce it to do so. Please open menu and click "Reconnect to Server" icon.

If Puffin still cannot connect to our server, please visit our feedback page and provide us more information.

Basic layout

Cara menggunakan change browser history javascript

Browse tabs: click "Tabs" icon on the URL bar to enter the tabbed browsing view. In this view, you can close all tabs by clicking the 'Trash can' icon.

Full Screen mode

Puffin supports Flash-based and HTML5-based full screen mode. While viewing Flash videos or playing Flash games, users would be notified that the full screen mode is available. The 'Enable Full Screen mode' icon is located right next to the Floating menu on the bottom of the screen. Click the icon to enter the full screen mode.

Another way to enter the full screen mode. Please go to menu and enable 'Theater mode' option. However, this option is only available for selected Flash video formats.

Cara menggunakan change browser history javascript

Flash tools and settings: In full screen mode, click 'More settings' icon, located at the bottom of the screen, to bring up the control panel. Please note that higher Flash quality requires more bandwidth, and it may result in slower page responsiveness in slow network.

Gamepad

In the Flash full screen mode, click the more option icon on the lower right corner, and click "Game Pad" icon to launch the virtual gamepad.

How to download

Puffin should automatically download a file when navigating to a file download URL. You may force Puffin to download a link by long-pressing on the link and selecting "Save Link". Then, you can save the file into your device or Google Drive.

To check the download status, click the main menu, and click the 'Download' icon on the bar. You will find the status from the list.

To access the file on your device, tap the completed download from the list. Then, you can choose other compatible apps to open the file.

To access files in your Google Drive, you need to use the Google Drive app or visit Google Drive website.

How to drag-n-drop

For Adobe Flash content, it is easy to perform drag-n-drop in full screen mode. Please enable "Theater" mode from the menu. Then, the pan gestures will be considered as 'drag-n-drop' in this mode.

Bring up the menu, and click "Mouse" icon. Long press around cursor and move to drag-n-drop.

Incognito mode

In the tabbed browsing view, click "Incognito" icon to enable "Incognito mode".

Scrolling to top / bottom

Scroll the page down and the 'scroll-to-bottom' icon will show up. Click the icon to fast forwad to the bottom of the page. Similarly, scroll the page up and the 'scroll-to-top' icon will show up.

Texts selection / Image save

Long press on text to bring up text selection tools. Long press on an image to bring up the pop-up menu to save the image. Please allow Puffin to access your photo album, or it cannot save images.

Managing bookmarks

Add Bookmark: Go to the Puffin main menu > Add bookmark.

Access Bookmarks: Go to Puffin main menu. Click the 'Bookmarks' icon on the top bar.

You can import your desktop bookmarks into Puffin Browser. Click the ellipsis icon > "Import" from the Bookmarks section. Then follow the instructions on the screen.

Set default download location

Your choice of the download location the first time Puffin asks where to save download files is kept as a default setting. The available choices are "Ask first", "Google Drive", "Internal shared storage", and "SD card". To change this, go to the main menu > Settings icon in the top bar and change the configuration of "Download Destination".

Change Data Savings settings

Puffin can save more bandwidth for you. Please go to Menu > Settings and change the configuration of 'Data savings'.

Display pages in Desktop mode or Mobile mode

Please go to Menu > Settings and change the configuration of 'Website preference.

Touch visual effect

Each time the user touches a web page, Puffin shows a blue circle visual effect. To turn if off, go to 'Settings' and turn off 'Touch visual effect'.

Clearing browsing data (History, cache, cookies, username and password)

To clear history, cache, cookies, or saved passwords, go to 'Settings' and configure 'Clear browsing data' to delete selected types of data from your device.

How to check Puffin's version?

Go to the main menu > "Settings" icon on the top bar. Find Puffin's version at the bottom.

How to switch between using the Trackpad and Smart pointer?

Cara menggunakan change browser history javascript

You can switch between using the Smart pointer and Trackpad in the main menu > Settings > Mouse.

How to use the smart pointer?

Bring up the menu, and click "Mouse" icon. Pan around cursor to move it. Pan outside of cursor to scroll the web page.

Bring up the navigation menu in the bottom left corner, and tap the "Mouse" icon. Long press around cursor and move to drag-n-drop.

Bring up the navigation menu in the bottom left corner, and tap the "Mouse" icon. Long press and release around cursor to trigger right click.

Limitations of Ad Blocker

Please note that turning on Ad Blocker may result in poor experiences on some websites.

Some examples include:

1. Websites may reject access when Ad Blocker is turned on.

2. Primary content (game or video) may not load correctly when an introductory ad video is blocked.

3. In some cases, the blocked ad video is considered to be still playing. The website may wait for its completion before you can continue.