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