tag:blogger.com,1999:blog-7192910.post3530129731755499265..comments2024-03-01T08:27:06.252-06:00Comments on PremierPoint Solutions Team Blog: Make Selected Links in a Links List Open in a New WindowPremierPoint Solutionshttp://www.blogger.com/profile/03668782854153322571noreply@blogger.comBlogger41125tag:blogger.com,1999:blog-7192910.post-63218875573631100502013-08-01T12:28:27.031-05:002013-08-01T12:28:27.031-05:00I have the Group By issue as well. The above reco...I have the Group By issue as well. The above recommendation does not work for me for some reason. Below is what I have (ignore the square brackets):<br /><br /><br />[script language="JavaScript"]<br /><br />$('.ms-vb2 a').live("click",function(){<br />rewriteLinks();<br /><br />});<br /><br />function rewriteLinks() {<br /> var anchors = document.getElementsByTagName("a");<br /> for (var x=0; x0) <br />{<br /> <br />oldText = anchors[x].outerHTML;<br />newText = oldText.replace(/#openinnewwindow/,'" target="_blank');<br /> <br />anchors[x].outerHTML = newText;<br /><br /> }<br /> }<br />}<br /><br />[/script]<br /><br />Genehttps://www.blogger.com/profile/02388139428661814592noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-40936909957008280492013-03-13T21:28:04.352-05:002013-03-13T21:28:04.352-05:00Someone mentioned this would not work with "g...Someone mentioned this would not work with "group by" enabled. I had the same issue - the anchors aren't there on page load.. so nothing to rewrite. I got around this also attaching the function to a click event for anchor tags in the webpart. <br /><br />$('.ms-vb2 a').live("click",function(){<br /> rewriteLinks();<br /><br />});GlobalWhispererhttps://www.blogger.com/profile/07112724778490677134noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-85253058494135045212013-03-13T21:23:43.016-05:002013-03-13T21:23:43.016-05:00Someone mentioned this would not work with Group B...Someone mentioned this would not work with Group By enabled.. I found the same problem.... the anchors are not loaded right away with the link list webpart I was using, so they were never rewritten. I got around this by attaching our rewrite links function to a click event like so:<br /><br />$('.ms-vb2 a').live("click",function(){<br /> rewriteLinks();<br /><br />});GlobalWhispererhttps://www.blogger.com/profile/07112724778490677134noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-80298594626130381072012-02-07T09:24:05.821-06:002012-02-07T09:24:05.821-06:00Mandeep - The reason I chose to have users add the...Mandeep - The reason I chose to have users add the #openinnewwindow, is it's the easiest way to control which links open in a new window and which ones don't. You certainly don't want every link on the page to open in a new window. :-)Ricky Spearshttps://www.blogger.com/profile/18114053887886617287noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-12647721152490642452012-01-24T10:59:38.825-06:002012-01-24T10:59:38.825-06:00I am a newbie to Sharepoint, and I respect the con...I am a newbie to Sharepoint, and I respect the contributors of this blog. Only One thing came to my mind while I was going through the suggested pieces of code and the author's solution. Don't you think it is unfair to ask the end user to remember to put #openinnewwindow after every link. And for all those experts to have agreed to this solution, I have a question. <br /><br />If you are trying to find the indexOf(#openinnewwindow), why can one not look up the indexOf(http) , and if its there add the target. And you don't need the next line of code to replace the #openinnewwidnow.<br /><br />This is obviously when all links are external and will have the (http) which in most cases and scenarios is true.<br /><br />I am sorry if this hurts anyone, and I look forward to any feedback/comments on this approach. Being a newbie I may be overlooking something which will nto work ideally with this solution. Please feel free to add your valuable input on my comment.<br /><br />Many Thanks<br />MandeepMandeephttps://www.blogger.com/profile/06747002281505670705noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-75273064300238226252011-02-17T10:41:14.523-06:002011-02-17T10:41:14.523-06:00Thanks! I really appreciate you taking the time t...Thanks! I really appreciate you taking the time to share this info and post it in a public place. The code worked great (copied it from your second attempt - where you indidcated that the first post may have stripped out some characters). I added it to my master page just before the /Head tag. Worked like a charm.Cowgirl Kendrahttps://www.blogger.com/profile/13223069122670892038noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-72444666737191109112010-08-26T10:57:48.210-05:002010-08-26T10:57:48.210-05:00dan - You're probably going to have to change ...dan - You're probably going to have to change the entire link from a direct link to a web page to a link to another JavaScript function that is capable of setting the window size. Here is a tutorial that might help get you started:<br />http://www.javascript-coder.com/window-popup/javascript-window-open.phtmlRicky Spearshttps://www.blogger.com/profile/18114053887886617287noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-18942484512129557982010-08-19T07:03:37.347-05:002010-08-19T07:03:37.347-05:00Does anyone know how I would edit the following co...Does anyone know how I would edit the following code to set the size of the new window to a 640 x 480 resolution? Thanks, Dan<br /><br />[script language="JavaScript"] <br /><br />_spBodyOnLoadFunctionNames.push("rewriteLinks");<br /><br /> <br /><br />function rewriteLinks() {<br /><br />//create an array to store all<br /><br />var anchors = document.getElementsByTagName("a");<br /><br /> <br /><br />//loop through the array<br /><br />for (var x=0; x0) {<br /><br />//add the [target] attribute and rewrite the [href] attribute<br /><br />anchors[x].target = "_blank";<br /><br />anchors[x].href = anchors[x].href.replace(/#openinnewwindow/,'');<br /><br />}<br /><br />}<br /><br />}<br /><br />[/script]Unknownhttps://www.blogger.com/profile/05361987307305888476noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-19157755339469641472010-08-15T13:38:31.230-05:002010-08-15T13:38:31.230-05:00Firefox doesn't seem to support the outerHTML....Firefox doesn't seem to support the outerHTML.indexOf code so this won't work in Firefox. Any idea how to get it to work?saxy46https://www.blogger.com/profile/06625051939752677170noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-56178325442801545422010-05-07T10:58:25.840-05:002010-05-07T10:58:25.840-05:00Doug - Thanks for the enhancement and for sharing ...Doug - Thanks for the enhancement and for sharing it!Ricky Spearshttps://www.blogger.com/profile/18114053887886617287noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-1534207609072604462010-04-29T09:10:53.021-05:002010-04-29T09:10:53.021-05:00Some of the script was stripped out in my previous...Some of the script was stripped out in my previous post. I will attempt to post it again in this post.<br /><br /><script language="JavaScript"> <br />_spBodyOnLoadFunctionNames.push("rewriteLinks");<br /> <br />function rewriteLinks() {<br /> //create an array to store all<br /> var anchors = document.getElementsByTagName("a");<br /> <br /> //loop through the array<br /> for (var x=0; x<anchors.length; x++) {<br /> //check to see if the current anchor element contain #openinnewwindow<br /> if (anchors[x].outerHTML.indexOf('#openinnewwindow')>0) {<br /> //add the [target] attribute and rewrite the [href] attribute<br /> anchors[x].target = "_blank";<br /> anchors[x].href = anchors[x].href.replace(/#openinnewwindow/,'');<br /> }<br /> }<br />}<br /></script><br /><br /><br />If all else fails I've posted here as well: http://www.sharepointlessonslearned.com/blogs/blog1.php/2010/04/28/open-link-list-items-in-new-windowUnknownhttps://www.blogger.com/profile/09211030347398856587noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-14268364206540559572010-04-28T10:44:54.260-05:002010-04-28T10:44:54.260-05:00Thanks for the post, it was a helpful start.
We t...Thanks for the post, it was a helpful start.<br /><br />We tweaked the originally posted javascript snippet and came up with this. It's simply adding a [target] attribute, and removing the '#openinnewwindow' string from the existing [href] attribute.<br /><br />*Remember (as noted above) replace the square brackets '[]' with angle brackets '<>' around the opening and closing script tags.<br /><br /><br />[script language="JavaScript"]<br /><br />_spBodyOnLoadFunctionNames.push("rewriteLinks");<br /><br />function rewriteLinks() {<br /> //create an array to store all<br /> var anchors = document.getElementsByTagName("a");<br /> <br /> //loop through the array<br /> for (var x=0; x0) {<br /> //add the [target] attribute and rewrite the [href] attribute<br /> anchors[x].target = "_blank";<br /> anchors[x].href = anchors[x].href.replace(/#openinnewwindow/,'');<br /> }<br /> }<br />}<br />[/script]Unknownhttps://www.blogger.com/profile/09211030347398856587noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-73277787223820608212010-04-01T16:31:45.605-05:002010-04-01T16:31:45.605-05:00I am trying to use this on a page that has a page ...I am trying to use this on a page that has a page viewer webpart. The page viewer web part references a word document with numerous links to pdfs, other word docs, excel docs, and external links, but when I click on a link, it does not open in a new window. <br /><br />I applied to to the page, within a CEWP and changed the reference to http://mysite/mypath instead of #openinnewbrowser, but no luck.<br /><br />Any ideas?Unknownhttps://www.blogger.com/profile/17207942509613856323noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-34786371930481706112010-01-27T08:21:37.584-06:002010-01-27T08:21:37.584-06:00Jeff - That's really odd. I can't see any ...Jeff - That's really odd. I can't see any reason this would happen unless the IF statement that checks for the presence of #OPENINNEWWINDOW isn't firing for some reason. I would check for any types (maybe copy and paste it in fresh again) or check for any conflicts in the variable names used in this script with the variable names used in any other scripts that run on that same page. Good luck!Ricky Spearshttps://www.blogger.com/profile/18114053887886617287noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-25091117140198440222010-01-25T15:13:41.777-06:002010-01-25T15:13:41.777-06:00The code works well except that now everything ope...The code works well except that now everything opens in a new window, regardless of whether or not it has the #openinnewwindow tag or not. Suggestions? Running MOSS 2007 Enterprise.Unknownhttps://www.blogger.com/profile/14973722953033737894noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-33405493943768843742009-11-20T21:00:19.140-06:002009-11-20T21:00:19.140-06:00I created a server-side only solution for this usi...I created a server-side only solution for this using an OpenInNewWindow Yes/No column and my HtmlFilter tool.<br /><br />http://rrfreeman.blogspot.com/2009/11/my-links-sharepoint-list-web-part-mods.htmlRobertRFreemanhttps://www.blogger.com/profile/06353151634970716780noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-47220724436203043452009-09-21T20:09:42.907-05:002009-09-21T20:09:42.907-05:00Thanks...this works great. However, i've notic...Thanks...this works great. However, i've noticed if I use this script on a page with "Group by" enabled it does not work. Any ideas on how to correct this?Webman09noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-39626875036085849462009-08-10T08:36:46.996-05:002009-08-10T08:36:46.996-05:00Works great.
Here is the code if you want to open ...Works great.<br />Here is the code if you want to open in a new windows without toolbars<br /> //does this anchor element contain #notoolbar?<br /> if (anchors[x].outerHTML.indexOf('#notoolbar')>0) {<br /> <br /> //store the HTML for this anchor element<br /> oldText = anchors[x].outerHTML;<br /> //alert(oldText);<br /><br /> <br /> //rewrite the URL to remove our test text and add a target instead<br /> newText = oldText.replace(/#notoolbar/,'" onclick="return popup(this);');<br /> //alert(newText);<br /> <br /> //write the HTML back to the browser<br /> anchors[x].outerHTML = newText; <br /> <br /> }<br /><br /><br /> }<br />}<br /><br />function popup(mylink) {<br /><br /> if (! window.focus)return true;<br /> var href;<br /> if (typeof(mylink) == 'string')<br /> href=mylink;<br /> else<br /> href=mylink.href;<br /> window.open(href, 'SharePoint', 'width=1200,height=850,toolbar=no,scrollbars=no');<br /> return false;<br />}SteFetSnoreply@blogger.comtag:blogger.com,1999:blog-7192910.post-42111317051889137832009-06-19T11:44:00.513-05:002009-06-19T11:44:00.513-05:00Thanks .. worked great..Thanks .. worked great..Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7192910.post-38493185215312399492009-06-12T04:16:16.869-05:002009-06-12T04:16:16.869-05:00it works at wss 3.0 sp2.
Look the post from wmhogg...it works at wss 3.0 sp2.<br />Look the post from wmhogg!<br />ThanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7192910.post-63651327071078629752009-05-28T06:13:58.366-05:002009-05-28T06:13:58.366-05:00is this solution not supposed to work with firefox...is this solution not supposed to work with firefox??? i got it to work in IE, but not firefox...any help will be much appreciated.Chiemhttps://www.blogger.com/profile/18203273238811027645noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-89304389115599657152009-05-27T08:45:35.234-05:002009-05-27T08:45:35.234-05:00Excellent Solution. Thanks for the post.Excellent Solution. Thanks for the post.Unknownhttps://www.blogger.com/profile/02371036394690026904noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-69761144471592371302008-12-08T21:06:00.000-06:002008-12-08T21:06:00.000-06:00Thanks for the easy fix - I am working with a grou...Thanks for the easy fix - I am working with a group of co-workers to set up a standard way that we store references as a subject matter expert -- they are not all going to go in and redo their html code. Some times a not so elegant fix is the best. Glad you offered bothJeanne Doney Rittersonhttps://www.blogger.com/profile/08445984425518384008noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-32530562443300872272008-06-25T10:24:00.000-05:002008-06-25T10:24:00.000-05:00Anonymous - Care to post a link to your post with ...Anonymous - Care to post a link to your post with the screenshots?Ricky Spearshttps://www.blogger.com/profile/18114053887886617287noreply@blogger.comtag:blogger.com,1999:blog-7192910.post-51146507827761180472008-06-24T16:05:00.000-05:002008-06-24T16:05:00.000-05:00This code works - but the instruction you posted i...This code works - but the instruction you posted is lacking. If you are going to use this JS code on the LINKS - then you have to add a content editor web part to the page, edit the content editor web part and put the js into the content editor web part. I wrote a procedure with screen shots.Anonymousnoreply@blogger.com