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

HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...javascript including in a pagejavascript including in a page
Previous
 
Next
New Post
11/24/2011 4:18 AM
 

hi all

i have a page in dornetnuke website including a div . in that div i want in the ready of the page, applying a javascript function.

When i include that function into the content of the page, it feels nothing and nothing happens in the page.

 

So, Can anyone help me and tell me how to apply a javascript function on it????

 

Thanks

 
New Post
11/24/2011 5:25 AM
 

Firstly - if you are trying to include javascript code in a HTML module by default you may find that it is being stripped out by default. As a result - there is no way that the javascript would function.

Secondly - I asp.net its not really practical to put code directly into the <BODY onload= element because the BODY tag is pretty much outside the perview of any modules.

As a result - the best way to trigger javascript code to run on page load with DNN or most CMS these days is using jQuery.  The jquery .ready() event is guaranteed to occur once the page HTML is loaded - with the added benefit that it does not wait till all the images are loaded.

<script>
$(document).ready(function() {
// your programming goes here

});
</script>

Westa

 
New Post
11/24/2011 6:06 AM
 

Thanks for your reply, but did you mean that i include that script tag in the same page i want javascript in?? or where should i put i?????


Thanks 

 
New Post
11/24/2011 6:43 AM
 

Make sure that jQuery is loaded.
example of ascx control:

 <%@ Control language="C#" Inherits="MyNamespace.MyModule.View" Codebehind="View.ascx.cs" %>

<script type="text/javascript">
    jQuery(document).ready(
        function () {
            Run this on load');
        }
    );   
</script>

<p>This is content of my control</p>

 
New Post
11/27/2011 8:01 AM
 

Thanks alot for your reply , i tried that code in skin page and it is working well.

But i tried to add it in to an aspx page but it still not working.

 

So, Any Help , Please...

 

Thanks

 
Previous
 
Next
HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...javascript including in a pagejavascript including in a page


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