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

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]".

share|improve this question
    
@FalakMahmood: Yes, in 2010. –  Jeremy Jan 9 '13 at 0:54

2 Answers 2

up vote 4 down vote accepted

It should work:

<UrlAction Url="javascript:void(window.open('http://www.google.com','_blank'))"/>
share|improve this answer
    
Yes! That works. Thanks for the update. –  Jeremy Jan 9 '13 at 1:35
    
Let's delete the comments :) –  Falak Mahmood Jan 9 '13 at 1:36

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

share|improve this answer
    
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

 
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.