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

We have a client that have their systems set up so that the Javascript in a Content Editor on a page does not seem to run unless they add the url of the site to the list of Trusted Sites in Internet Explorer. Here is the java script:

<script type="text/javascript">

// Copyright (c) 2010 Christophe Humbert - Path to SharePoint

// Find all Web Parts in the page
var listWP=[],calWP=[],divs=document.getElementById("MSO_ContentTable").getElementsByTagName("div");
var count=divs.length;
for (i=0;i<count;i++) {
try {
if (divs[i].id.indexOf("WebPartWPQ")==0){
if (divs[i].innerHTML.indexOf("ViewDefault_CalendarView")>=0) {
// Calendars
calWP.push(divs[i].id);
}
else {
// Other Web Parts
listWP.push(divs[i].id);
}
}
}
catch(e){}
}

function TextToHTML(NodeSet, HTMLregexp) {
var CellContent = "";
var i=0;
while (i < NodeSet.length){
try {
CellContent = NodeSet[i].innerText || NodeSet[i].textContent;
if (HTMLregexp.test(CellContent)) {NodeSet[i].innerHTML = CellContent;}
}
catch(err){}
i=i+1;
}
}

var regexpA = new RegExp("\\s*<([a-zA-Z]*)(.|\\s)*/\\1?>\\s*$");
var regexpTD = new RegExp("^\\s*<([a-zA-Z]*)(.|\\s)*/\\1?>\\s*$");

var WP = new Object;

function UpdateWP() {
if (calWP.length>0){
for (i=0;i<calWP.length;i++) {
WP=document.getElementById(calWP[i]);
if (WP.innerHTML.indexOf("&lt\;")>=0) {TextToHTML(WP.getElementsByTagName("a"),regexpA);}
}
}
if (listWP.length>0){
for (i=0;i<listWP.length;i++) {
WP=document.getElementById(listWP[i]);
if (WP.innerHTML.indexOf("&lt\;")>=0) {TextToHTML(WP.getElementsByTagName("td"),regexpTD);}
}
}
// Check every 200 ms, forever
setTimeout("UpdateWP()",200);
}
UpdateWP();

</script>

<script type="text/javascript">
    var currheight = document.documentElement.clientHeight;window.onresize = function()
                                                                             {    
                                                                                if(currheight != document.documentElement.clientHeight) 
                                                                                {        
                                                                                    location.replace(location.href);    
                                                                                }    
                                                                             }
</script>
<style type="text/css">
    .ms-acal-mdiv
    {
        margin:0px !important;
        padding:0px !important;
        height:auto !important;
    .ms-acal-item
    {
        background:none;
        border:0;
    } 
    .ms-acal-time 
    {
        display:none;
    } 
    .ms-acal-sdiv 
    {
        position:relative;
        width:100%;
    }
    .ms-acal-sdiv a 
    {
        position:absolute;
        left:0px;
        width:100%;
    } 
    .ms-acal-sdiv .ms-acal-title 
    {
        padding-top:0px;
        height:35px;
    }
</style>

Can anyone point me in the direction of why this script won't run while other script runs just fine on their browsers.

TIA

share|improve this question
1  
hey, that's my script :-) –  Christophe Dec 20 '11 at 16:23
add comment

1 Answer 1

up vote 1 down vote accepted

I actually see two scripts here.

The first one is mine and should be fine.

The second one seems to try and work with an iframe. This will be an issue if the content of the iframe is not in the same domain as the main page. You're saying that it works with trusted sites, my bet is that you are using Internet Explorer. You won't be so lucky with other browsers.

share|improve this answer
    
Do you mean the <script type="text/javascript"> var currheight = document.documentElement.clientHeight;window.onresize = function() { if(currheight != document.documentElement.clientHeight) { location.replace(location.href); } } </script> –  MikeC Dec 20 '11 at 18:02
    
Yes. I am not sure what it is supposed to do, but it seems like you are working with multiple windows or iframes. –  Christophe Dec 20 '11 at 18:12
add 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.