On our SharePoint list, we have anchor tags opening in a new window via:
<script type="text/javascript" src="/SiteAssets/jquery-latest.min.js"></script>
<script type="text/javascript">
$(function() {
var $t = $("table.ms-listviewtable>tbody tr td:nth-child(4) a");
var interval = setInterval(function() {
$t.each(function(){
$(this).attr("target", "_blank");
});
}, 1000);
});
</script>
When you hit page 2 in the list, the anchor tags open in the same window, and via "Inspect Element" do not contain the "target="_blank" like on the first page.
The jQuery code above is in a CEWP which points to a .txt file containing the code via CEWP property of "Content Link :: To link to a text file, type a URL."
I can't figure out why 2nd page is causing this issue. If I go back to 1st page, from 2nd page, the jQuery doesn't work either. In the query string, the URL has appended "?PageView=Shared&InitialTabId=Ribbon.WebPartPage&VisibilityContext=WSSWebPartPage#I"
If I take this string noted above off the end of the URL, and the view name is the last thing in the URL (viewname.aspx), the jQuery works on page 1.
04.21.15 using this now as working solution:
$(function() { var $t; var interval = setInterval(function() { $t = $("table.ms-listviewtable>tbody tr td:nth-child(4) a"); $t.each(function(){ $(this).attr("target", "_blank"); }); }, 1000); });