3

I have added a menu item to the Personal Actions menu by creating a CustomAction like so:

<CustomAction
    Id="myCustomAction"
    GroupId="PersonalActions"
    Location="Microsoft.SharePoint.StandardMenu"
    Sequence="1000"
    Title="My Link"
    Description="This is my custom link."
>
    <UrlAction Url="http://www.example.com/" />
</CustomAction>

I want that URL to open in a new window. I have tried this in the UrlAction,

<UrlAction Url="javascript:window.open('http://www.example.com/', '_blank');" />

but it causes the first window's content to be replaced with the text "[object]". Is there a better way to do this?

EDIT: When I run it with Firebug open, the behavior is slightly different. The first window's URL changed to "javascript:window.open('http://www.example.com/', '_blank');" and its content changed to "[object Window]".

  • @FalakMahmood: Yes, in 2010. – Jeremy Jan 9 '13 at 0:54
4

It should work:

<UrlAction Url="javascript:void(window.open('http://www.google.com','_blank'))"/>
  • Let's delete the comments :) – Falak Mahmood Jan 9 '13 at 1:36
0

Here is an excerpt from the msdn page that seems to achieve what you are looking to do

 <CommandUIHandler Command="{4E2F5DC0-FE2C-4466-BB2D-3ED0D1917763}" CommandAction="javascript:window.open('http://www.bing.com/search?q='.concat(escape(document.title)))" />

And this is the link to where I found it http://msdn.microsoft.com/en-us/library/hh500259(v=office.14).aspx#odc_sp14_ta_AddCustomActiontoDisplay_CustomActionElements

Hope its what you need

  • I'm not quite sure where to put the CommandUIHandler element. I'm not adding a ribbon button, which might be the problem. – Jeremy Jan 9 '13 at 1:09
  • It would go inplace of the <UrlAction> although UrlAction should be working – user13186 Jan 9 '13 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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