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 want to change the "New Item" text into "Yeni Ekle". I viewed the source of the list from browser. Here is the part of the New Item;

<a id="idHomePageNewItem" ...........>
  <span ...>
    <img id="idHomePageNewItem-img" ....></img>
  </span>
  <span>  new item  </span>
</a> 

And here is my code for change the text. But it doesn't work. Why doesn't it work?

Updated:

<asp:content contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">
    <SharePoint:RssLink runat="server"/>
    <SharePoint:scriptlink ID="ScriptLink" Name="SP.js" runat="server" OnDemand="true" Localizable="false"></SharePoint:ScriptLink> 
    <script type="text/javascript" src="/../../../Style Library/SolidQ-SPS-JS.js"></script>
    <script type="text/javascript">
        ExecuteOrDelayUntilScriptLoaded(ChangeText,"sp.js");
        function ChangeText() {
          document.getElementById('idHomePageNewItem').getElementsByTag("span")[1].innerHTML="Yeni Ekle";
        }
    </script>
</asp:content>
share|improve this question

2 Answers 2

up vote 1 down vote accepted

Try change getElementsByTag to "getElementsByTagName" as that is the valid Javascript DOM selector

share|improve this answer
    
It worked finally.. Thank you –  e.ozmen Mar 15 '13 at 9:34

There could be multiple reasons, either your javascript is executing before the control text has been rendered, or your selection method is not correct.

Have you tried triggering the function manually after the page has fully loaded from the console?

share|improve this answer
    
Doesn't $().ready trigger the function? –  e.ozmen Mar 15 '13 at 8:30
    
Well it does, but it has a tendency in sharepoint to trigger before all sharepoints javascript functions has executed. I usually use ExecuteOrDelayUntilScriptLoaded() and specify sp.js or sp.ui.socialribbon.js as the script to wait for just to make sure –  Robert Lindgren Mar 15 '13 at 8:37
    
I updated the javascript part. It doesn't work. Did I write it wrong? –  e.ozmen Mar 15 '13 at 8:47
    
Yes, you should only write the functions name as the first parameter in ExecuteOrDelay.. Like ExecuteOrDelayUntilScriptLoaded(ChangeText,"sp.js"); –  Robert Lindgren Mar 15 '13 at 8:50
    
Should I import anything for sp.js? –  e.ozmen Mar 15 '13 at 8:55

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.