Sharepoint and Javascript.  Works in IE but not in Chrome.

Posted on 2013-12-05
Last Modified: 2014-02-19
I have a Content Editor webpart on a Sharepoint page that is reference a file with the script below.  It works fine in IE but not in Chrome.  Going further into the issue i setup a simple alert("test"); and in IE it would work every time I refreshed the page.  In Chrome it would run once and never again.

What I basically am doing is pulling values from a query string and populating them in a DIV on the page.

<script language="javascript">

var RegionVar;
var DepotVar;
var ProgramVar;

function GetUrlValue(VarSearch){
    var SearchString =;
    var VariableArray = SearchString.split('&');
    for(var i = 0; i < VariableArray.length; i++){
        var KeyValuePair = VariableArray[i].split('=');
        if(KeyValuePair[0] == VarSearch){
            return KeyValuePair[1];


function SetDynamicData(){

RegionVar = GetUrlValue('Region');
DepotVar = GetUrlValue('depot');
ProgramVar= GetUrlValue('program');

document.getElementById("titlebardiv").innerHTML=(DepotVar.replace(/%20/gi, " "));
document.getElementById("programbardiv").innerHTML=(ProgramVar.replace(/%20/gi, " "));

window.onload=SetDynamicData ;


Open in new window

Question by:tyty4u2
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 44

Accepted Solution

Rainer Jeschor earned 500 total points
ID: 39699727
which SharePoint version?

I would be really really careful to use window.onload - especially with SharePoint.

Could you simply try to replace
window.onload=SetDynamicData ;

Open in new window


Open in new window


Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question