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

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Call jscript file from HTML page (or use tag)Call jscript file from HTML page (or use tag)
Previous
 
Next
New Post
1/8/2011 8:17 AM
 

Hoist the white flag – struth!

The Mission: Add a button on web page that when clicked will open popup window.

Placed jscript (directly below) into skin and referenced on web page with html call function that follows. It successfully loads popup window.

<script  language="javascript">

var popupWindow = null;

function centeredPopup(url,winName,w,h,scroll){

LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;

TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

settings =

'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'

popupWindow = window.open(url,winName,settings)

}

</script>

 

Call script on html page

 

<a onClick="centeredPopup(this.href,'myWindow','500','300','yes');return false" href="http://www.quackit.com/common/link_builder.cfm">Centered Popup</a>

 

Works Bonza! U little ripper.

 

Now need to do 2 things:

********************

 

1. Put that jscript into separate file in portal root folder to enable all web sites to use. [So added code into separate .js file and placed in ~httpdocs/js/ folder. This seemed a logical thing to do – correct?]

 

Now this is where it gets tricky.

 

2. To link to an external JavaScript file, you add a src attribute to your HTML script tag and specify the location of the external JavaScript file.

Linking to an external JavaScript file

<script type="text/javascript" src="external_javascript.js"></script>
 
SO I COULD REFERENCE THIS TO MY LOCATION:
 
<script type="text/javascript" src="~httpdocs/js/[Name].js"></script>
 
In other words I uploaded the new .js file into the js folder and used the above lingo i.e. syntax
 
IS THE SYNTAX CORRECT ? Why cant I make it run from my web page or skin? I am not repeating the script tag in the skin 
[even if you give me a clue with some code that calls script file from another location that will help]
 
3. To make it run from Command Button I would add onClick event handler to a command button. Bonza i.e sound good?
 
 
4. Finally – whilst this is all beaut, adding the script to the html on the web page is not ideal. The main reason is that you cannot use the rich text editor as it strips out script – 
who was the the drongo who thought of that? How could can I avoid? Alternative suggestions to run script?

Can you create a tag associated with the script that can be added to call the script/ popup widnow from any page?
 
Well if anyone can have a Captain Cook at this, help guide me through Bass Strait & give me the good oil I would sure appreciate.
 
Good on ya
 
Hooroo from Oz
 
New Post
1/8/2011 11:05 AM
 
Hello,
your syntax is not correct, the tilde (~) is used by asp.net to calculate paths, and can't be used in javascript. There are a number of ways people handle this

1. get their module to move the script to a root folder (or a folder such js), and use a path such as src="/js/script.js"
2. include the js file with their skin, and use the <%= SkinPath %> token to build the path e.g. src="<%skinpath%>/script.js" (the skin processor in dotnetnuke will replace the skinpath variable instances with the path to the actual skin.

As to invoking the event, if you're using an asp.net server control such as button, the onClick event will fire a server-side click event, if you want to run javascript you use the OnClientClick event (see http://msdn.microsoft.com/en-us/libra... ). if you're using a normal html control i.e, <input type=button... then the onClick event is fine.

As to javascript being stripped, that's a function of the editor rather than DotNetNuke (it's possible to get the radeditor to allow script , see http://www.telerik.com/community/foru... ), but most people simply switch to the basic text box, paste their script and then save (without switching back to rich text editor). Also, many people simply add such script in either the page header or footer (edit the page to see those fields). Finally, some people use modules such as http://wnsinj.codeplex.com/ to control javascript injection.

Thanks,
Cathal


Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
1/8/2011 2:37 PM
 

Thanks Cathal

Your a gem - you have given me some good advice and ideas how to deal with.

Will have a muck around later today and see how I get on.

What I love about DNN and the community is how much you learn every time you try something - amazingly powerfl resource when you consider the number of people involved. Will leave you with that phiisophical thought as a freewill gift. offering which is perhaps only marginally more than mates rates - but at least its something! :)

Feel free to delete this post if you wish.

Miles
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Call jscript file from HTML page (or use tag)Call jscript file from HTML page (or use tag)


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