-
Notifications
You must be signed in to change notification settings - Fork 1
/
viewitdirect.js
30 lines (27 loc) · 1.49 KB
/
viewitdirect.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Make your "View It" link go directly to the source instead of opening an embedded box.
Essentially it copies the link from the title of the search result to the View It link.
It doesn't actually suppress the opening of the embedded box, but by using the same window to go to the resource it has the same effect.
See in action by searching http://primo-direct-apac.hosted.exlibrisgroup.com/primo_library/libweb/action/search.do?vid=LIN and clicking "View Online" on any record. */
function getElementsByClass (string,containerId) {
var classElements = new Array();
( containerId === undefined ) ? containerId = document : containerId = document.getElementById(containerId);
var allElements = containerId.getElementsByTagName('*');
for (var i = 0; i < allElements.length; i++) {
var multiClass = allElements[i].className.split(' ');
for (var j = 0; j < multiClass.length; j++)
if (multiClass[j] === string)
classElements[classElements.length] = allElements[i];
}
return classElements;
}
function viewOnlineHandler() {
var theResult = this.parentNode.parentNode.parentNode.parentNode.parentNode;
var theUrl = theResult.children[0].children[0].children[0].children[0].href;
location.href = theUrl;
}
var results = getElementsByClass('EXLSummary');
for (i=1; i<results.length; i++) {
if (results[i].children[0].children[0].children[0].children[0].href != null) {
results[i].children[1].children[3].children[0].children[0].children[3].onclick = viewOnlineHandler;
}
}