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 an issue with custom action.

Here is the definition of my custom action:

  <CustomAction
          Id="GoToDefi"
          Title="Go To"
          Description="Go To"
          RequireSiteAdministrator="FALSE"
          RegistrationType="ContentType"
          RegistrationId="0x01"
          GroupId="ActionsMenu"
          Location="DisplayFormToolbar"
          Sequence="1000">
    <UrlAction Url="javascript:GoToFunction();"/>
  </CustomAction>

So basically this is bound to CT and in display item form when i click on it, it doesnt redirect to anywhere, it just refereshes and that is it.

Here is the function code:

function GoToFunction()
{
    //Some extra steps are done

     window.location.href = "www.google.com";
}

Any idea what am i missing?

UPDATE:

I noticed a bit strange behaviour, when i hover over my link, i see that it has javascript:_dopstostback(...); But not my script.

When i do the debugging, my script is wel being called, but i think this _doPostBack overwrites my changes. I checkthed the html and i see following:

....
<tr>
<td class="ms-toolbar" nowrap="nowrap" >
   <a id="....toolbartbl_rpControls_ct112" href="javascript:_doPostBack('ct1000....','')"/>
   <a id="....toolbartbl_rptControls_CT112_LinkText" href="javascript:myfunction();" />
</td>

I don't know why but there are 2 anchor elemenets, and i think that postback is breaking my redirection.

But if in my custom action i give url like that url='www.google.com' then both of elements have href to www.google.com. But if i use any kind of javascript then it is not working anymore.

share|improve this question
add comment

2 Answers

Are you using an older version of IE? Previously IE hade problems with redirecting with href. Try if this line of code works:

window.navigate("http://www.google.com");
share|improve this answer
    
No, this solution doesn't work either, and i tested and for example i can redirect to other page, if i use this call for example on document ready, but in the function it doesnt :( –  Shkipper Feb 28 '13 at 7:25
    
Can you see if your method is actually loaded at all? And maybee try som console.log() to see that the code line is actually executed –  Robert Lindgren Feb 28 '13 at 7:29
    
yes, i noticed something strange, ill update my post in a sec –  Shkipper Feb 28 '13 at 8:22
add comment

how about removing the last part ;) :

function GoToFunction()
{
    //Some extra steps are done

     window.location = "www.google.com";
}

if it was 2010 it would of been easy ;) ,

try adding javascript:void so like this:

  <CustomAction
          Id="GoToDefi"
          Title="Go To"
          Description="Go To"
          RequireSiteAdministrator="FALSE"
          RegistrationType="ContentType"
          RegistrationId="0x01"
          GroupId="ActionsMenu"
          Location="DisplayFormToolbar"
          Sequence="1000">
    <UrlAction Url="javascript:void GoToFunction();"/>
  </CustomAction>
share|improve this answer
    
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. –  Mike Feb 27 '13 at 17:17
    
That's a valid answer, albeit not very informative as to why. window.location.href doesn't always work. –  PirateEric Feb 27 '13 at 19:26
    
i tried this also but it didn't work :) –  Shkipper Feb 27 '13 at 20:15
    
is this in 2010 or 2007? –  ali Sharepoint Feb 28 '13 at 12:57
    
it is SharePoint 2007 –  Shkipper Mar 1 '13 at 8:49
show 1 more 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.