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 a sharepoint site . The javascripts seems to be working only for my home page . If i naviagate to any other pages , the javascripts are not getting executed . I observed the behavior in chrome browser the most .

share|improve this question
    
Are there any errors in the console? –  RJ Cuthbertson Jun 27 at 20:28
    
Looks like i have the issue mentioned :withinsharepoint.com/archives/256 –  Nikhil Jun 27 at 20:34
    
Uncaught ReferenceError: MoveSiteTitle is not defined –  Nikhil Jun 27 at 20:35
    
Uncaught ReferenceError: documentGetElementsByName is not defined –  Nikhil Jun 27 at 20:36
    
apart from home page . Any idea as to why above errors are occurring on all other pages ? ar TitleWPID = 'g_994e5206_37b2_4edb_ace7_a1fa8396e660'; // ]]> </script><script type="text/javascript"> // <![CDATA[ var logoImg = documentGetElementsByName('onetidHeadbnnr0'); if (logoImg != undefined && logoImg[0] != undefined) logoImg[0].src='/_layouts/images/siteIcon.png'; // ]]> </script><script type="text/javascript"> // <![CDATA[ MoveSiteTitle(); // ]]> –  Nikhil Jun 27 at 21:01

3 Answers 3

If your comments are an actual script tag in your master page - you have a syntax error on your master page which will kill all the rest of the javascript on the page.

You're missing a dot and javascript is case sensitive, so you need 'document.getElementsByName' not 'documentGetElementsByName'

var logoImg = document.getElementsByName(...)

I'm also assuming MoveSiteTitle() is a function that would otherwise be available if that first inline script was working -- but you should also make sure it is globally available.

share|improve this answer

To check whether javascript is working or not do the following

1) Insert a Script Editor in your web page. 2) Enter the following code inside the editor.

alert("javascript is working");
share|improve this answer
    
Right , its not popping :) –  Nikhil Jun 27 at 20:49
up vote 0 down vote accepted

When viewing SharePoint 2010 from the Chrome browser, intermittently the page will load but fail to call it’s JavaScript initialization functions leaving the page only partially functional.

Put this code at the bottom of the master page file just before the closing body tag. PS : http://mosswell.blogspot.com/2013/06/sharepoint-2010-and-chrome-javascript.html

<script type="text/javascript">
/*****************
 *  
 * Code to handle the SharePoint / Chome bug
 *
 *****************/

function chromeNudge() {
    /// <summary>
    /// If SharePoints body onload handler has not fired yet
    /// this function calls it manually
    /// </summary>
    if (!_spBodyOnLoadCalled) {
        if (window.console) {
            window.console.log('Chrome Bug: _spBodyOnLoadWrapper did not fire, calling manually.');
        }
        _spBodyOnLoadWrapper();
    }
}

function chromeNudgeDelay() {
    /// <summary>
    /// If the current browser is Chrome, set a Timeout
    /// to call chromeNudge to at that time evaluate
    /// whether the onload wrapper needs a "nudge"
    /// </summary>
    if (navigator && navigator.userAgent && /chrome/.test(navigator.userAgent.toLowerCase())) {
        setTimeout(chromeNudge, 250);
    }
}

// call chromeNudgeDelay after MS Ajax init event (aka body load)
Sys.Application.add_init(chromeNudgeDelay);

share|improve this answer

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.