Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Javascript not running when inserted into a Text/HTML module (in IE)Javascript not running when inserted into a Text/HTML module (in IE)
Previous
 
Next
New Post
5/16/2013 6:15 AM
 

I am trying to use a piece of JavaScript inside a Text/HTML module.

Its a countdown clock and it fails to display all the countdown numbers in IE 6,7,8 and 9).
It does work ok in all Non-IE Browsers and IE 10, but not in older versions of IE.
However it does work when used outside DNN environment (on all browsers and all version of IE).

This is the Header bit and the JavaScript code (I've placed it inside Settings >> Advanced Settings):

 <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="css/countdown.css" rel="stylesheet" type="text/css"  />    

<script type="text/javascript">
var current="&nbsp; &nbsp; LGPS &nbsp; 2014&nbsp; is &nbsp;here!"   
var year=2014;   
var month=04;    
var day=01;     
var hour=00;    
var minute=00; 
var tz=0;       

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

function countdown(yr,m,d,hr,min){
    theyear=yr;themonth=m;theday=d;thehour=hr;theminute=min;
    var today=new Date();
    var todayy=today.getYear();
    if (todayy < 1000) {todayy+=1900;}
    var todaym=today.getMonth();
    var todayd=today.getDate();
    var todayh=today.getHours();
    var todaymin=today.getMinutes();
    var todaysec=today.getSeconds();
    var todaystring1=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
    var todaystring=Date.parse(todaystring1)+(tz*1000*60*60);
    var futurestring1=(montharray[m-1]+" "+d+", "+yr+" "+hr+":"+min);
    var futurestring=Date.parse(futurestring1)-(today.getTimezoneOffset()*(1000*60));
    var dd=futurestring-todaystring;
    var dday=Math.floor(dd/(60*60*1000*24)*1);
    var dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
    var dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
    var dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
    if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=0){
        document.getElementById('count2').innerHTML=current;
        document.getElementById('count2').style.display="inline";
        document.getElementById('count2').style.width="390px";
        document.getElementById('dday').style.display="none";
        document.getElementById('dhour').style.display="none";
        document.getElementById('dmin').style.display="none";
        document.getElementById('dsec').style.display="none";
        document.getElementById('days').style.display="none";
        document.getElementById('hours').style.display="none";
        document.getElementById('minutes').style.display="none";
        document.getElementById('seconds').style.display="none";
        document.getElementById('spacer1').style.display="none";
        document.getElementById('spacer2').style.display="none";
        return;
    }
    else {
        document.getElementById('count2').style.display="none";
        document.getElementById('dday').innerHTML=dday;
        document.getElementById('dhour').innerHTML=dhour;
        document.getElementById('dmin').innerHTML=dmin;
        document.getElementById('dsec').innerHTML=dsec;
        setTimeout("countdown(theyear,themonth,theday,thehour,theminute)",1000);
    }
}
</script>  
</head>
<body onload="countdown(year,month,day,hour,minute);">
</body>


This is the HTML inside the Text/HTML module editor:
<table background="alldials.png" width="710px" height="105px" cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td width="355" cellpadding="0" cellspacing="0" border="0">
        <span class="strapline">
            <a href="http://www.sypensions.org.uk/FutureLGPSNews/tabid/629/language/en-GB/Default.aspx"><img src="clickHere.png" width="185px" border="0"></a>
        </span>
    </td>
    <td width="355">
        <table id="table" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td><div id="count2"></div></td>
            </tr>
            <tr id="spacer1">
                <td align="center"> <div class="numbersD" id="dday"> </div> </td>
                <td align="center"> <div class="numbersH" id="dhour"> </div> </td>
                <td align="center"> <div class="numbersM" id="dmin"> </div> </td>
                <td align="center"> <div class="numbersS" id="dsec"> </div> </td>
            </tr>
        </table>
    </td>
  </tr>
</table>

 I'm wondering if its to do with the actual doctype on my DotNetNuke page?
Because it does work outside DNN and does work in IE10 and other non-IE browsers in this way above.

thanks,
Mark.

 
New Post
5/16/2013 8:11 AM
 
Mark,

I would suggest not to inject Javascript using an HTML module. I recommend the Content Injection Module for DotNetNuke by Will Strohl: http://wnsinj.codeplex.com/

That gives you much mor control over what you want to do.

Best wishes
Michael

Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
5/17/2013 2:43 AM
 
Hi
If you are getting problem in running js code from HTML module, then there is still option to add the script to your skin file. But from HTML module it should work.

Thanks,
Sunil Kumar [ DNN Developer, Mindfire Solutions,India ]
 
New Post
5/17/2013 2:53 AM
 
Sunil,

please tell me the reason for putting a Javascript to a skin file when you need this script on one page. This is a bit of an overhead. The module I mentioned in my post above does great work for that, and you have the choice where you want the script to be placed during rendering.

And: you can inject any type of content (meta-tags etc.).

Best wishes
Michael

Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
5/17/2013 3:09 AM
 
Micheal,
Most of the times we make one separate skin file for home page and one for all internal pages.
Thats why i suggested to do so thinking that the html module used in the home page. Any way this is a option i suggested. User will use it if they think it will work for them.
And thanks for the module you suggested.

Thanks,
Sunil Kumar [ DNN Developer, Mindfire Solutions,India ]
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Javascript not running when inserted into a Text/HTML module (in IE)Javascript not running when inserted into a Text/HTML module (in IE)


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out