 Rank: Member Joined: 10/22/2015(UTC) Posts: 31  Thanks: 1 times
|
Originally Posted by: Scott  Quote:Is 'JoinPanel.SupportPromptVisible' an iframe? Is that why the code above does not work with the pop-up? No, I believe it's just a div created within our modal dialog framework. As to why it's not working I'm not sure, are you attempting to override the prototype for window.open()? You could try not adding the handler to the PreRender and just instead load it into the DOM directly (but likely still filtering on the page type). What does the code look like that invokes your 'popUp' method? I simply want the page that is linked in 'JoinPanel.SupportPromptMessage' to open in a new window, of the size specified. Below is the code I have for the 'JoinPanel.SupportPromptMessage' pop-up: Code:<p style="font-weight:bold;">You must accept our <a href="https://www.mysite.com/support/index.php?/Knowledgebase/Article/View/1345/15/remote-support-policy" target='_blank' onclick="popUp(this.href,'elasticNoC',1010,725);return false;">Terms & Conditions</a> before continuing.</p>
Below is the code for my extension: Initializer.js: Code:
SC.event.addGlobalHandler(SC.event.PreRender, function (eventArgs) {
if (SC.context.pageType == 'GuestPage'){
// JavaScript Document
var newWin = null;
function popUp(strURL, strType, strWidth, strHeight) {
LeftPosition = (screen.width) ? (screen.width-strWidth)/2 : 0;
TopPosition = (screen.height) ? (screen.height-strHeight)/2 : 0;
if (newWin != null && !newWin.closed)
newWin.close();
var strOptions="";
if (strType=="consoleC")
strOptions="resizable,top="+TopPosition+',left='+LeftPosition+",height="+
strHeight+",width="+strWidth;
if (strType=="fixedC")
strOptions="status,top="+TopPosition+',left='+LeftPosition+",height="+
strHeight+",width="+strWidth;
if (strType=="elasticC")
strOptions="toolbar,menubar,scrollbars,"+
"resizable,location,top="+TopPosition+',left='+LeftPosition+",height="+
strHeight+",width="+strWidth;
if (strType=="elasticNoC")
strOptions="scrollbars,"+
"resizable,top="+TopPosition+',left='+LeftPosition+",height="+
strHeight+",width="+strWidth;
if (strType=="console")
strOptions="resizable,height="+
strHeight+",width="+strWidth;
if (strType=="fixed")
strOptions="status,height="+
strHeight+",width="+strWidth;
if (strType=="elastic")
strOptions="toolbar,menubar,scrollbars,"+
"resizable,location,height="+
strHeight+",width="+strWidth;
if (strType=="elasticNo")
strOptions="scrollbars,"+
"resizable,height="+
strHeight+",width="+strWidth;
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
}
}
});
manifest.xml: Code:
<?xml version="1.0" encoding="utf-8"?>
<ExtensionManifest>
<Version>1.0</Version>
<Name>TEST - Add Window Resize JS</Name>
<Author></Author>
<ShortDescription>The bare minimum needed for a new extension.</ShortDescription>
<Components>
<ClientScriptInitializer SourceFile="Initializer.js" />
</Components>
</ExtensionManifest>
My extension does not work but if I simply delete or disable the extension and paste the following code to the bottom of the 'Global.js' file, it works. Code:
// JavaScript Document
var newWin = null;
function popUp(strURL, strType, strWidth, strHeight) {
LeftPosition = (screen.width) ? (screen.width-strWidth)/2 : 0;
TopPosition = (screen.height) ? (screen.height-strHeight)/2 : 0;
if (newWin != null && !newWin.closed)
newWin.close();
var strOptions="";
if (strType=="consoleC")
strOptions="resizable,top="+TopPosition+',left='+LeftPosition+",height="+
strHeight+",width="+strWidth;
if (strType=="fixedC")
strOptions="status,top="+TopPosition+',left='+LeftPosition+",height="+
strHeight+",width="+strWidth;
if (strType=="elasticC")
strOptions="toolbar,menubar,scrollbars,"+
"resizable,location,top="+TopPosition+',left='+LeftPosition+",height="+
strHeight+",width="+strWidth;
if (strType=="elasticNoC")
strOptions="scrollbars,"+
"resizable,top="+TopPosition+',left='+LeftPosition+",height="+
strHeight+",width="+strWidth;
if (strType=="console")
strOptions="resizable,height="+
strHeight+",width="+strWidth;
if (strType=="fixed")
strOptions="status,height="+
strHeight+",width="+strWidth;
if (strType=="elastic")
strOptions="toolbar,menubar,scrollbars,"+
"resizable,location,height="+
strHeight+",width="+strWidth;
if (strType=="elasticNo")
strOptions="scrollbars,"+
"resizable,height="+
strHeight+",width="+strWidth;
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
}
|