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

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIAddBodyOnloadEventHandler issueAddBodyOnloadEventHandler issue
Previous
 
Next
New Post
9/24/2008 7:47 PM
 
I am working on a custom Skin Object to perform various client side tasks.  I have my Javascript in it's own JS file which needs to initialized in the body onload event.  According to the DotNetNuke Client API documentation, the correct way to accomplish this is to use DotNetNuke.UI.Utilities.ClientAPI.RegisterStartUpScript to include my script and DotNetNuke.UI.Utilities.DNNClientAPI.AddBodyOnloadEventHandler to call my initialization function.  It all seems straight forward, however, when deployed the fruits of my efforts, nothing happened.  I verified that the Page Source included the client script but the onload function never fires.  I have since backed my code down to just the following code running in the Page_Load event:
Dim strScript As String = "<script type='text/javascript' src='/Resources/Scripts/prc.js'></script>" & _
 "<script type='text/javascript'>" & vbNewLine & _
 "//<![CDATA[" & vbNewLine & _
 "function __prc_Initialize() { try { prc.Initialize(); } catch (ex) { nable to initialize \'prc\' client API.'); } }" & vbNewLine & _
 "//]]>" & vbNewLine & _
 "</script>" & vbNewLine
 
'DotNetNuke.UI.Utilities.ClientAPI.RegisterStartUpScript(Me.Page, "prc.Initialize", strScript)
DotNetNuke.UI.Utilities.DNNClientAPI.AddBodyOnloadEventHandler(Me.Page, " dnn_onload');")    ' "__prc_Initialize();")
 
Yet the JS alert still never fires.  Here is an exerpt from the page source which is exactly what I expected:
<input name="__dnnVariable" type="hidden" id="__dnnVariable" value="&#11;__dnn_pageload&#12; dnn_onload');&#11;<snip/>" />
As you can see it is there ready for to be evaluated but does not fire.  We are still using DNN 4.6.2 with many custom modules, many using AjaxPro and AjaxControlToolkit without issue.
I must be missing something.  Please advise.
Thanks in advance for your help.
 
New Post
9/25/2008 8:47 AM
 

From reading your code, not sure what the point of showing the strScript is since is never is used (its commented out).  Also you aren't trying to call it, instead you are trying to call dnn_onload.  This needs to be changed to dnn_onload() so the function gets called.  Not sure where your script is for dnn_onload.  Try changing it to 1) to do an easy test.  If you could post a url to a sample page, I would be able to isolate the problem easier.

 


 
New Post
9/25/2008 1:47 PM
 

The point of that code is only to display a JS client-side dd_onload'); to indicate the the function was called.  If this would work, I would uncomment the and use my routines.  If doesn't work, what is the point?  I tried to make it the most simple test possible.  I included my other code simply to show my intention.  The JS does not fire in my portal.

Any ideas?

Thanks.

 
New Post
9/26/2008 8:28 AM
 

try changing dd_onload to

a l e r t ( 1 )

without spaces.  Does that work?  If so then make sure you specify dd_onload() with parens as I mentioned earlier.  Does that work?


 
New Post
9/29/2008 5:31 PM
 

I determined that there was other Javascript high-jacking the window.onload event, in an external <script /> tag that had been pasted into an Text-HTML module.  I appreciate your input.

Thank you.

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIAddBodyOnloadEventHandler issueAddBodyOnloadEventHandler issue


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