7

I have created an Item selector application which shows the directory structure on the aspx page. On click of any file in this structure will set the file path in tridion's component field. I am attaching the image for component strucuture.

enter image description here

Here I have a season component with episode as a multi-valued embedded field. Episode schema is also having an embedded field to select media links which has a field for custom url which opens up the aspx page.

For first episode when I click the custom page link it work fine and open up in pop up. The issue which I am facing is that when I add second episode and click the custom url link it get opened in new tab instead of pop up. I have also found that in IE8 it is working fine on my machine but not on IE8 on other machine.

In chrome and firefox it is not working.

11
  • 1
    Few information needed: 1) Have you created your own Item Selector or have used the one already available as the Community Extension - If it is former one, then can you verify for possible bugs in it. 2) IE8 on other machine and Chrome/Firfox issue - is it having all the right settings for opening a pop-up and executing a JS? Commented Jun 25, 2013 at 7:51
  • 1
    Very long shot: It's a multiple-value field. The next field is loaded/added asynch. Could it be that the JavaScript event to open the custom page isn't added to the newly added field? (Because it's loaded async?) Not sure (yet) on how to test this... Commented Jul 9, 2013 at 18:30
  • 1
    The behavior of Custom URL opening is the same as the one which opens History dialog for instance, if you have this dialog working correct (and browser independent), then the issue is in your code somewhere. If this dialog does not work correct then the issue is in Tridion and should be reported. Commented Jul 11, 2013 at 8:36
  • 1
    "I have also found that in IE8 it is working fine on my machine but not on IE8 on other machine." - can you confirm both instances of IE don't have any active plugins - you need to find a consistent test base/replication pattern first. Are you also sure that the second instance of the field/popup is not conflicting with the first (e.g. unique ID/path etc.)? Commented Jul 12, 2013 at 8:03
  • 1
    If it is working fine on one machine and not on others, then I would say it is not an issue of the browser or SDL Tridion, but an issue in the configuration of the browsers on the machines where it is not working? Commented Jul 18, 2013 at 13:27

1 Answer 1

1

It has been somewhat of a mystery to me how the JavaScript window.open() command behaves. You will find several explanations on the internet that you should use things like:

window.open("www.yoururl.com", "_blank");

or

window.open("www.yoururl.com", "_newtab");

But in some cases your browser will simply refuse to open in a new tab and do it in a popup window. When working on my View in Staging and Live UI extension, I finally figured out how this behavior works, with thanks to this answer on Stack Overflow;

window.open() will not open in new tab if it is not happening on actual click event.

If the window.open() method is called on an actual click event, it should always open in a new tab, unless you set window size properties. This will of course only work if the user has appropriate settings in his browser.

So as a developer you most of the time have control over how you call this method, and thus how you want the window to be opened. In my mentioned extension, I was initially calling window.open() in a event handler method, so window.open() was called asynchronously and thus no matter what I used, it always opened in a popup window, rather than a tab. To solve this I have used the following code:

// open window on actual click event with about:blank page
var tab = window.open("", "some name");

// event handler
var onItemLoaded = function whatever$_execute$_onItemLoaded() {
    $evt.removeEventHandler(item, "load", onItemLoaded);

    // some code to determine the url from the loaded item
    var url = siteUrl + item.path;

    // open url in tab and set focus
    tab.location.href = url;
    tab.focus();
};

// load item asynchronously
$evt.addEventHandler(item, "load", onItemLoaded);
item.load(item.isLoaded(true), $const.OpenMode.VIEW);

Now that is the explanation why sometimes when you want to open a window in a tab, it can just open as a popup window. But on IE I have also seen a different behavior which I can only explain as a defect in IE. As the OP has mentioned, in most cases the window is opened as expected (in a popup window). So this code must use the following call (or something like it):

window.open("www.theurl.com", "window name", "width=500,height=600");

It should never, in any case, open in a new tab, as it is called with the specs argument. But I have seen this behavior before (opening in a popup window once and in a tab later), and only on older IE browsers. So the only thing I can conclude from that, is that this is a defect in IE...

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.