It’s not easy task to support both “Load a web page using Ajax” and “Allow to open the same page in browser new tab”. Because we have to manually handle the second option. Let’s see how to solve this task.
Before proceeding, first you have to know why ajax web pages are not able to support the second option.
Reason : when you click a web page link, it will just invoke a javascript method specified in onclick event which loads the page through ajax requests. So here “href” attribute of anchor tag is either empty or “javascript:void(0);”. Due to this we are not able to open the page in new tab.
Sample code for achieving both the actions
* ajax page load
* the same page should be able to open in Browser New Tab by using “Open Link in New Tab” option.
Two operations handled in the web page links(anchor tags),
* invoke the method showPage when u click the link. which means simply onclick event gets fired.
* if u open the same link in new tab, the below sequence of actions will execute.
o # part of href(say, #/blogs/JSON/json-basics.html) has appended to the browser url
o showtab method has invoked beco’z the main page gets loaded. rest will take care of the method showtab

COMMENTS
No Comments