How to add javascript code in DNN website PAge
Last Post 04/20/2011 1:23 PM by Joseph Craig. 21 Replies.
Author Messages
Vandana g
Nuke Newbie
Nuke Newbie
Posts:1


--
09/11/2006 4:07 AM  
Can anybody tell me how to add javascript code into the DNN website page.
Lee Sykes
DNN Creative Staff
Nuke Master VI
Nuke Master VI
Posts:4945


--
09/11/2006 6:53 AM  
There are several methods you can use:

1) place it directly in a Text / HTML module. - Click on HTML and enter the Javascript, do not click on Text after you have entered the Javascript and just click on Update.

2) place it in your skin - so this can go in the skin.htm or skin.ascx file depending on how you are creating your skins. You can see how this is done with the Google Adsense tutorials:
Incorporating Google Adsense into DotNetNuke Skins

3) You can also call a Javascript file, this method is outlined in the sIFR and DotNetNuke – Video Tutorial

Hope this helps,

Thanks,
Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/DNNCreative

Lee Sykes's Facebook Profile
David Lumley
Nuke Newbie
Nuke Newbie
Posts:1


--
09/25/2006 6:26 AM  
Hello
I have a site I am tyrying to port to DNN it has a simple javascript marquee - do you think it is worth writing a simple module to run this javascript
If so where would you suggest starting?? - the java script has a few parameters that would sit nicely in the settings dialogue

Kenis Polanco
Nuke Pro
Nuke Pro
Posts:63


--
09/25/2006 11:05 AM  
Hi lee,
 
I have been working on sIFR and DotNetNuke – Video Tutorial, andI ran into some problems
 
The main problem involves javascript, video 5. I follow the tutorial copied and paste the code from sIFR folder to my default file and made the appropriate changes and I get this error from vwd debugger which points to
 
Page.Header.Controls.AddAt(0, New LiteralControl(Comment)) line 145 in the default.aspx.vb
 
Here is a copy of my default file:
 
<%@ Page Language="vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.Framework.DefaultPage" CodeFile="Default.aspx.vb" %>
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Common.Controls" Assembly="DotNetNuke" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<head id="Head" runat="server">
   
    <meta id="MetaRefresh" runat="Server" name="Refresh" />
    <meta id="MetaDescription" runat="Server" name="DESCRIPTION" />
    <meta id="MetaKeywords" runat="Server" name="KEYWORDS" />
    <meta id="MetaCopyright" runat="Server" name="COPYRIGHT" />
    <meta id="MetaGenerator" runat="Server" name="GENERATOR" />
    <meta id="MetaAuthor" runat="Server" name="AUTHOR" />
    <meta name="RESOURCE-TYPE" content="DOCUMENT"/>
    <meta name="DISTRIBUTION" content="GLOBAL"/>
    <meta name="ROBOTS" content="INDEX, FOLLOW"/>
    <meta name="REVISIT-AFTER" content="1 DAYS"/>
    <meta name="RATING" content="GENERAL"/>
    <meta http-equiv="PAGE-ENTER" content="RevealTrans(Duration=0,Transition=1)"/>
    <style id="StylePlaceholder" runat="server"></style>
    <asp:placeholder id="CSS" runat="server"></asp:placeholder>
    <script src="<%= Page.ResolveUrl("js/dnncore.js") %>"></script>
    <script src="<%= Page.ResolveUrl("js/sifr.js") %>" type="text/javascript"></script>
    <script src="<%= Page.ResolveUrl("js/sifr-addons.js") %>" type="text/javascript"></script>
   
</head>
<body id="Body" runat="server" bottommargin="0" leftmargin="0" topmargin="0" rightmargin="0" marginwidth="0" marginheight="0">
    <noscript></noscript>
    <dnn:Form id="Form" runat="server" ENCTYPE="multipart/form-data" style="”height: 100%;">
        <asp:Label ID="SkinError" runat="server" CssClass="NormalRed" Visible="False"></asp:Label>
        <asp:PlaceHolder ID="SkinPlaceHolder" runat="server" />
        <input id="ScrollTop" runat="server" name="ScrollTop" type="hidden">
        <input id="__dnnVariable" runat="server" name="__dnnVariable" type="hidden">
    </dnn:Form>
</body>
</html>
 
Lee Sykes
DNN Creative Staff
Nuke Master VI
Nuke Master VI
Posts:4945


--
09/25/2006 11:48 AM  

Hello,

You need to read the addendum for that tutorial:
sIFR and DotNetNuke – Video Tutorial

At the bottom it tells you what you need to do with DNN 4.3 and includes some code for download, thanks,

Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/DNNCreative

Lee Sykes's Facebook Profile
Kenis Polanco
Nuke Pro
Nuke Pro
Posts:63


--
09/25/2006 8:41 PM  
Hi lee,
 
I follow the instruction in the addendum for DotNetNuke 4.3.x
 
However I get this error:
 
htmlfile: Could not set the innerHTML property. Invalid target element for this operation. In my js/sifr.js file
 
on line 7:
 
 
Lee Sykes
DNN Creative Staff
Nuke Master VI
Nuke Master VI
Posts:4945


--
09/26/2006 3:47 AM  
Can you confirm which 4.3 version you are using?

Did you remove the changes from the default.aspx file that you made? and just upload the new Default.aspx.vb?
Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/DNNCreative

Lee Sykes's Facebook Profile
Kenis Polanco
Nuke Pro
Nuke Pro
Posts:63


--
09/28/2006 8:11 AM  
Hi lee,
 
The version I am currently using is 4.3.3
 
I did remove the code from the default.aspx file
 
And then I copied and paste the codes:
 
Page.ClientScript.RegisterClientScriptInclude("sifr", ResolveUrl("~/js/sifr.js"))
Page.ClientScript.RegisterClientScriptInclude("sifr-addons", ResolveUrl("~/js/sifr-addons.js"))
 
Right under line 212
Lee Sykes
DNN Creative Staff
Nuke Master VI
Nuke Master VI
Posts:4945


--
09/28/2006 8:20 AM  
That sounds completely correct. I can't test it in 4.3.3 however as I don't have that version on my system anymore.

It is recommended that you upgrade to 4.3.5 as it fixes a lot of bugs - including potential security problems.

At this stage I would suggest an upgrade and then try again as it appears as though you have done everything correctly.
Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/DNNCreative

Lee Sykes's Facebook Profile
Lee Sykes
DNN Creative Staff
Nuke Master VI
Nuke Master VI
Posts:4945


--
09/28/2006 8:25 AM  
Hello,

Just reading through the code above for the second time you have:

<script src="<%= Page.ResolveUrl("js/dnncore.js") %>"></script>

in the default file. Are you sure you are working in 4.3.3 and not 4.0.3?

The line above only occurs in 4.0.3 and below
Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/DNNCreative

Lee Sykes's Facebook Profile
Kenis Polanco
Nuke Pro
Nuke Pro
Posts:63


--
09/28/2006 9:34 AM  
I placed that line of code base on video 5 and then remove it
And followed the instruction to code in the appropriate line of codes
On my Default.aspx.vb
 
However I think I might be running version 4.0.3.
 
Lee Sykes
DNN Creative Staff
Nuke Master VI
Nuke Master VI
Posts:4945


--
09/28/2006 9:53 AM  
You can check which version of DNN you are currently running by going to host / host settings and it will state the version at the top of that page.

If you added that line of code in, it sounds as though you are using 4.3.3 - if you are I would really recommend to upgrade to 4.3.5 for all of the security fixes.
Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/DNNCreative

Lee Sykes's Facebook Profile
Kenis Polanco
Nuke Pro
Nuke Pro
Posts:63


--
09/28/2006 1:30 PM  
I have upgraded from 4.3.3 to 4.3.5 into a new website to start the process over
 
However, the samething that happened to me with the previous DotNetNuke version (4.0.3, 4.3.3) has happen to me again
 
Which is for some reason when I try to login as host or admin it goes back to the home
Page with out being logged in
 
I don’t fully understand how I fixed it the last few time but I think it deals with making a new website
And eventually it works?
 
Lee Sykes
DNN Creative Staff
Nuke Master VI
Nuke Master VI
Posts:4945


--
09/28/2006 3:15 PM  
Hello,

Did you follow these points in this tutorial?
http://www.dnncreative.com/Howtoupg...fault.aspx

The same process applies for upgrading 4.3.3 to 4.3.5

It sounds as though you haven't copied across all of the details from your web.config file - have you copied these from the original file:
  • <add key="MachineValidationKey" value="DB02CB97BAE1814E49F1310895EC33B22FC70014" />
  • <add key="MachineDecryptionKey" value="6E324A6FF2B87D590B71D61FDD95C82A137C980893117CF0"/>
  • <add key="InstallationDate" value="11/19/2005" />
It's the machine keys and installation date that are different for every single installation and DNN uses these to interpret the login details. - If these are wrong it will just log you back out and send you to the home page.
Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/DNNCreative

Lee Sykes's Facebook Profile
Kenis Polanco
Nuke Pro
Nuke Pro
Posts:63


--
09/29/2006 8:05 AM  
Hi lee,
 
The website I am running is under localhost for now
 
As far as I am concern I don’t need to change the autoupgrade
 
I did tranfer the add keys (MachineValidationKey, MachineDecreptionKey, InstallationDate) to the realese.config file. Though I think is the other way around?
 
I tried to delete the old database base on an error with the
assembly to communicate with the database
 
I had no problem doing this in the previous version (4.3.3)
 
I then created a new database and now the website is working
But with out any display of images on the leftPane, RightPane, contentPane ect…?
Elisa Walts
Posts:10


--
03/23/2007 11:19 AM  
I have added javascript to my code as below in the Text/HTML module. However, it's not finding the javascript when I go to run it. In IE when I debug it says "line 0- object expected". I get a new window to open but nothing is displayed. I am using DNN 3.3.7 I think. I copied this code from another web site I've done that is outside DNN and it works fine.

Am I missing something?

You can see the page at: http://www.robfin.com:89/Products/P...fault.aspx

Thanks for any help!
Lisa

-----------------------

<script type=text/javascript>

function transferview(image,width,height)
{

s1 ="Image"
s15=""
s2 ="


"
s3 ="<form>>"
s4 ="</form>
"

ImageWindow=window.open("", "largerview","toolbar=no,scrollbars=no,menubar=no,width=300,height=350");
ImageWindow.document.write(s1+s15+s2+s3+s4)
ImageWindow.document.close()

}

</script>


















Click to enlarge


  • caption for 1
Click to enlarge


  • caption for 2
Click to enlarge


  • caption for 3
Elisa Walts
Posts:10


--
04/26/2007 10:24 AM  
Finally solved it - turns out, at least in DNN 3 and using built-in html editor that any javascript code added to the html/text module gets deleted somewhere along the way. I put it in the page settings under header and it works fine.
Elisa Walts
Posts:10


--
04/26/2007 10:28 AM  
Oops - I meant the text/html Advanced settings under header.
samual
Nuke Newbie
Nuke Newbie
Posts:2


--
02/12/2010 7:23 AM  
Go to the edit content option and then select basic text box and put your js code there n see it works...
R3
Nuke Active Member
Nuke Active Member
Posts:32


--
04/20/2011 1:11 PM  
I have been trying to add this

<script language="javascript" type="text/javascript" src="http://www.clocklink.com/embed.js"></script> <br /> <br /> into the header of the HTML/text module. Can you please advise me to why this isn't working? <br /> <br /> Although I do know asp.net/html and so on, I don't have much experience with javascript. Any help would be much appreciated.
R3
Nuke Active Member
Nuke Active Member
Posts:32


--
04/20/2011 1:22 PM  
nvm, I found the problem and fixed it

I was missing the following

<script src="http://www.clocklink.com/embed.js"></script><script type="text/javascript" language="JavaScript">obj=new Object;obj.clockfile="world001-blue.swf";obj.TimeZone="PST";obj.width=480;obj.height=250;obj.wmode="transparent";showClock(obj);</script>
Joseph Craig
DNN MVP
Posts:11667


--
04/20/2011 1:23 PM  
When you say it isn't working, is that because you don't see it doing anything? The script that you specify just inserts some function definitions. You also need to add the code to execute the functions.

(I pasted your text into the header of an HTML module and it works just fine. You can look at the page source to see that it's there, and you can look at the contents of the page to verify that the file is loaded.)

Joe Craig, Patapsco Research Group
Complete DNN Support


---