5

In Tridion 2009, we could force the windows size from the schema by providing the following line of text in the Custom URL field of the schema;

/CustomURLs/hello/Helloagain/HelloPage.asp,950,600,saveandclose

This does not seem to be working in 2011. I know we can control it within the .asp file but want the ability to control it from the custom URL field in the schema. Any ideas?

1
  • I didn't know you could control the size from the URL in 2009. If you think this is a breaking change, I'd recommend filing a support ticket. Doesn't look like it's something you can easily work around. The easiest would be to read those parameters from your custom page and apply them.
    – Nuno Linhares
    Aug 2, 2013 at 18:53

1 Answer 1

4

What you were doing in 2009 was basically a hack (it was never documented, as far as I know, in the official documentation), because the Custom URL was used directly in a Javascript call to open a new window, basically by adding commas to your string you are specifying more parameters. Your example is adding a width and height and a window name to make the string fit correctly in the call.

This was not supported and shouldn't ever have worked (no proper input checking was done on this parameter), it is basically almost as bad as allowing SQL injection or those kind of hacks.

So you have noticed that as of 2011, a better mechanism is used to open the Custom URL window, which also does not allow this type of hacks anymore. But there is a very easy way to set the correct window size, using window.resizeTo(width, height)

<html>
  <head>
    <title>my custom url page</title>
    <script type="text/javascript" language="javascript" src="/WebUI/Core/Controls/Popup/PopupInit.js"></script>
    <script>
      function init()
      {
        window.resizeTo(500, 500);
      }
    </script>
  </head>
  <body onload="init();">
    <!-- my custom url page -->
  </body>
</html> 

By the way when using an ASP or ASPX page, make sure you don't refresh, reload or post inside the page, as that will clear the window.dialogArguments parameter so you cannot access the Component window that opened your popup anymore. In that case you should really use an iframe like I do in my Item Selector Custom URL example.

update

Reading your question again, I'll add an update to my answer. You indicate you don't want to control it inside the Custom URL page, but from the custom URL. Really as of 2011 the only way to control the size of the popup window is by using window.resizeTo(width, height), but that doesn't mean you cannot build something that would allow you to specify the size anymore. Just specify the width and height as URL parameters and read them using Javascript, something like this should work (with your Custom URL /path/mypage.html?width=950&height=600):

function getParameterByName(name) {
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search);
  return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

function init()
{
  var width = getParameterByName("width");
  var height = getParameterByName("height");
  if (width != "" && height != "") 
  {
    window.resizeTo(width, height);
  }
}
5
  • I think this is what I was looking for. I will give it a try.
    – BryanD
    Aug 5, 2013 at 16:31
  • So, would I put this code in the page that the custom URL is pointing to and would my custom URL line in the custom URL field look like this; /path/mypage.html?width=950&height=600?
    – BryanD
    Aug 5, 2013 at 16:47
  • yes that is exactly it Aug 6, 2013 at 7:02
  • @user525 what is the status of this question, if my answer worked for you, could you accept it, or if it is still open I would like to see an update/edit so we can try to provide you with a better answer? Aug 26, 2013 at 10:25
  • Haven't been able to circle back to do this. I believe it will work though. This is what I was looking for. Thank you.
    – BryanD
    Sep 3, 2013 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.