Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We have recently upgraded from SharePoint 2007 to SharePoint 2010. Now whenever a user clicks on a workflow to run on a list item it opens the initiation form in a new window. I have gotten 20+ complaints on this issue but cannot find where I can change the workflow anchor links to remove target="_blank". Is there a way to customize the dialog that lists the workflows that you can run on the items? Perhaps I can inject a JavaScript file to remove the target attribute?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Since workflows are listed in application page (_layouts/Workflow.aspx) two options for customization (remove the target attribute via JavaScript) are preferable here:

1 Add the JavaScript reference using Custom Action (ScriptSrc)

 <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
      ScriptSrc="SE/workflows.js"
      Location="ScriptLink"
      Sequence="88"
      >
  </CustomAction>
</Elements> 

2 Add the JavaScript reference to the Master Page (for example, via SPD)

For more details about Custom Action usage and another options please follow article REFERENCING JAVASCRIPT FILES WITH SHAREPOINT 2010 CUSTOM ACTIONS USING SCIPTSRC

share|improve this answer
    
In case anyone in the future needs assistance with this there are a couple of gotcha's that you should consider. First being that the links are generated on the fly so you need to run the jQuery AFTER the page is fully loaded and all links are populated. You can wrap the code from Benny's answer above in a window.setTimeout(removelinks(), 500) to have it execute after the links are populated on the screen. Secondly gotcha is that once the user runs the workflow the popup window does not close so you will need to find a way to have it close after the workflow has been run. –  LukeP Nov 13 '13 at 18:36
    
What I did to fix the second problem stated in my above comment was to change Benny's code to this $('a[target="_blank"]').attr('target','_parent'); this makes it so that rather than opening in a new tab it will target the current window. –  LukeP Nov 13 '13 at 19:12
add comment

You can do this using jQuery:

$('a[target="_blank"]').removeAttr('target');

Reference: jQuery/JavaScript - Remove All target="_blank"

share|improve this answer
    
Thank you for the code but I do not know where to put it. Is there some place in SharePoint designer that I can go to place this snippet so that it applies to the Workflow popup window? –  LukeP Nov 12 '13 at 19:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.