1

I'm trying to alter a redirect page layout so that when the redirect happens it will open in a new tab. I believe this section is the part that controls the redirect.

<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">
<PublishingWebControls:RedirectControl SecondsBeforeRedirect="5" runat="server"/>
<div class="redirect">
    <SharePointWebControls:FormField FieldName="RedirectURL" runat="server"/>
    <PublishingWebControls:RichImageField FieldName="PublishingRollupImage" runat="server"/>
    <PublishingWebControls:EditModePanel runat="server" CssClass="edit-mode-panel title-edit">
        <SharePointWebControls:TextField runat="server" FieldName="Title"/>
    </PublishingWebControls:EditModePanel>
</div>

How do I alter this to allow the redirect to open in a new tab?

1 Answer 1

0

I realized later that my question didn't actually make sense. It's not a redirect if you're opening a new tab.

I found that if I added a FieldValue with RedirectUrl fieldname, then it would create an anchor with the href that I wanted.

So, I added another EditModePanel with display on, and added a hidden div with an id of redirect-url. Within it, I placed the RedirectUrl field. Then I added javascript to gather that url, and open a new window.

<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">
<PublishingWebControls:RedirectControl SecondsBeforeRedirect="5" 
runat="server"/>
<div class="redirect">
    <SharePointWebControls:FormField FieldName="RedirectURL" 
    runat="server"/>
    <PublishingWebControls:RichImageField FieldName="PublishingRollupImage" 
    runat="server"/>
    <PublishingWebControls:EditModePanel runat="server" CssClass="edit-mode-
    panel title-edit">
        <SharePointWebControls:TextField runat="server" FieldName="Title"/>
    </PublishingWebControls:EditModePanel>

    <PublishingWebControls:EditModePanel runat="server" 
    PageDisplayMode="Display">
        <div style="display:none;" id="redirect-url">
            <SharePointWebControls:FieldValue FieldName="RedirectURL" 
            runat="server" />
        </div>
    <script>
    $(document).ready(function(){
        var url = $("#redirect-url a").attr("href");
        var target = "_blank";
        window.open(url, target);
    });
    </script>
</div>
</asp:Content>

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.