Issue:
Have a web page whose links open in same window. However, you want all links within a specific part of the page to load into a new tab/window. (For example, the search results from a search)
Solution:
You could do a page-wide default and then have the logic that spits out the results include it, but hard coding that does scale well or adapt to web side GUI changes. Solution, is to do it within the GUI since the "problem" is in the front-side GUI.
Here is a JavaScript solution:
a. Around the search results, add a new DIV like so:
<div id="searchviewbody" name="searchviewbody">$$ViewBody</div>
b. Then add the following to the JSHeader:
function SearchLinksTarget()
{
// get search div
searchDiv = document.getElementById('searchviewbody');
// get the div links
divlinks = searchDiv .getElementsByTagName('a');
// Loop through those links and attach the target attribute
for (var i=0, len=divlinks.length; i < len; i++) {
// the _blank will make the link open in new window
divlinks[i].setAttribute('target', '_blank');
}
}
c: Then add the following to the onLoad event:
SearchLinksTarget();
previous page
|